@kne/fastify-task 3.0.0-alpha.10 → 3.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -212,7 +212,17 @@ const createContext = (fastify, options) => {
|
|
|
212
212
|
const getTaskDeclaration = type => {
|
|
213
213
|
const declaration = resolveTaskDeclaration(type);
|
|
214
214
|
if (!declaration) {
|
|
215
|
-
|
|
215
|
+
const { taskName } = splitTaskName(type);
|
|
216
|
+
return registerTaskDeclaration({
|
|
217
|
+
namespace: mainNamespace,
|
|
218
|
+
taskName,
|
|
219
|
+
dirs: options.dirs,
|
|
220
|
+
scriptName: options.scriptName,
|
|
221
|
+
config: {},
|
|
222
|
+
override: false,
|
|
223
|
+
syncLegacyTask: false,
|
|
224
|
+
useGlobalDirs: true
|
|
225
|
+
}).declaration;
|
|
216
226
|
}
|
|
217
227
|
return declaration;
|
|
218
228
|
};
|
|
@@ -43,6 +43,13 @@ const getHour = (date, tz) => {
|
|
|
43
43
|
return d.hour();
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
const getZonedChannelHour = (periodTime, serverHour, tz) => {
|
|
47
|
+
if (!tz) return { date: formatDate(periodTime), hour: serverHour };
|
|
48
|
+
const localPeriodTime = dayjs(periodTime).hour(serverHour).minute(0).second(0).millisecond(0);
|
|
49
|
+
const zonedTime = localPeriodTime.tz(tz);
|
|
50
|
+
return { date: zonedTime.format('YYYY-MM-DD'), hour: zonedTime.hour() };
|
|
51
|
+
};
|
|
52
|
+
|
|
46
53
|
const safeNum = v => {
|
|
47
54
|
const n = Number(v);
|
|
48
55
|
return (typeof n === 'number' && !isNaN(n) ? n : 0);
|
|
@@ -333,10 +340,10 @@ const queryHourlyChildChannels = async (statisticsServices, { channels, startTim
|
|
|
333
340
|
|
|
334
341
|
const sum = getSumData(item);
|
|
335
342
|
const count = safeNum(sum.total);
|
|
336
|
-
const date =
|
|
343
|
+
const { date, hour } = getZonedChannelHour(item.time, completedHour, tz);
|
|
337
344
|
mergeHourlyItem(result, {
|
|
338
345
|
date,
|
|
339
|
-
hour
|
|
346
|
+
hour,
|
|
340
347
|
typeName,
|
|
341
348
|
runnerTypeName,
|
|
342
349
|
count,
|