Explorar o código

refs 111686: apply feedback

Futa Arai %!s(int64=3) %!d(string=hai) anos
pai
achega
0bb44ac052

+ 1 - 1
packages/app/.env.development

@@ -17,7 +17,7 @@ ELASTICSEARCH_REJECT_UNAUTHORIZED=true
 HACKMD_URI="http://localhost:3010"
 HACKMD_URI="http://localhost:3010"
 HACKMD_URI_FOR_SERVER="http://hackmd:3000"
 HACKMD_URI_FOR_SERVER="http://hackmd:3000"
 OGP_URI="http://ogp:8088"
 OGP_URI="http://ogp:8088"
-GROWI_QUESTIONNAIRE_URI="http://host.docker.internal:3003"
+GROWI_QUESTIONNAIRE_SERVER_ORIGIN="http://host.docker.internal:3003"
 # DRAWIO_URI="http://localhost:8080/?offline=1&https=0"
 # DRAWIO_URI="http://localhost:8080/?offline=1&https=0"
 # S2SMSG_PUBSUB_SERVER_TYPE=nchan
 # S2SMSG_PUBSUB_SERVER_TYPE=nchan
 # PUBLISH_OPEN_API=true
 # PUBLISH_OPEN_API=true

+ 2 - 2
packages/app/src/server/service/config-loader.ts

@@ -646,9 +646,9 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type: ValueType.STRING,
     type: ValueType.STRING,
     default: null,
     default: null,
   },
   },
-  GROWI_QUESTIONNAIRE_URI: {
+  GROWI_QUESTIONNAIRE_SERVER_ORIGIN: {
     ns: 'crowi',
     ns: 'crowi',
-    key: 'app:growiQuestionnaireUri',
+    key: 'app:growiQuestionnaireServerOrigin',
     type: ValueType.STRING,
     type: ValueType.STRING,
     default: null,
     default: null,
   },
   },

+ 4 - 5
packages/app/src/server/service/questionnaire-cron.ts

@@ -1,4 +1,5 @@
 import axios from '~/utils/axios';
 import axios from '~/utils/axios';
+import { sleep } from '~/utils/sleep';
 
 
 const nodeCron = require('node-cron');
 const nodeCron = require('node-cron');
 
 
@@ -8,11 +9,9 @@ const getRandomInt = (min: number, max: number): number => {
   return Math.floor(Math.random() * (maxInt - minInt) + minInt);
   return Math.floor(Math.random() * (maxInt - minInt) + minInt);
 };
 };
 
 
-const sleep = msec => new Promise(resolve => setTimeout(resolve, msec));
-
 class QuestionnaireCronService {
 class QuestionnaireCronService {
 
 
-  growiQuestionnaireUri: string;
+  growiQuestionnaireServerOrigin: string;
 
 
   cronSchedule: string;
   cronSchedule: string;
 
 
@@ -20,7 +19,7 @@ class QuestionnaireCronService {
 
 
   // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
   // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
   constructor(crowi) {
   constructor(crowi) {
-    this.growiQuestionnaireUri = crowi.configManager?.getConfig('crowi', 'app:growiQuestionnaireUri');
+    this.growiQuestionnaireServerOrigin = crowi.configManager?.getConfig('crowi', 'app:growiQuestionnaireServerOrigin');
     this.cronSchedule = crowi.configManager?.getConfig('crowi', 'app:questionnaireCronSchedule');
     this.cronSchedule = crowi.configManager?.getConfig('crowi', 'app:questionnaireCronSchedule');
     this.maxHoursUntilRequest = crowi.configManager?.getConfig('crowi', 'app:questionnaireCronMaxHoursUntilRequest');
     this.maxHoursUntilRequest = crowi.configManager?.getConfig('crowi', 'app:questionnaireCronMaxHoursUntilRequest');
   }
   }
@@ -37,7 +36,7 @@ class QuestionnaireCronService {
       await sleep(secToSleep * 1000);
       await sleep(secToSleep * 1000);
 
 
       try {
       try {
-        const response = await axios.get(`${this.growiQuestionnaireUri}/questionnaire-order/index`);
+        const response = await axios.get(`${this.growiQuestionnaireServerOrigin}/questionnaire-order/index`);
         console.log(response.data);
         console.log(response.data);
       }
       }
       catch (e) {
       catch (e) {

+ 1 - 0
packages/app/src/utils/sleep.ts

@@ -0,0 +1 @@
+export const sleep = (msec: number): Promise<void> => new Promise(resolve => setTimeout(resolve, msec));