|
|
@@ -26,6 +26,9 @@ async function run() {
|
|
|
const yesterdayYYYYMMDD = yesterday.format("YYYYMMDD");
|
|
|
const yesterdayStart = yesterday.startOf("day").toDate();
|
|
|
const yesterdayEnd = yesterday.endOf("day").toDate();
|
|
|
+ // 格式化日期字符串,使其符合 ClickHouse 的 toDateTime() 函数要求
|
|
|
+ const yesterdayStartString = (0, dayjs_1.default)(yesterdayStart).format("YYYY-MM-DD HH:mm:ss");
|
|
|
+ const yesterdayEndString = (0, dayjs_1.default)(yesterdayEnd).format("YYYY-MM-DD HH:mm:ss");
|
|
|
console.log(`[DoneRate Cron] Processing data for date: ${yesterdayYYYYMMDD}`);
|
|
|
let remoteConn = null;
|
|
|
let updatedRemoteArtworksCount = 0;
|
|
|
@@ -38,8 +41,8 @@ async function run() {
|
|
|
count(DISTINCT uid) AS unique_starts
|
|
|
FROM ${CLICKHOUSE_EVENTS_TABLE}
|
|
|
WHERE event = 'color_start'
|
|
|
- AND time >= toDateTime('${(0, dayjs_1.default)(yesterdayStart).toISOString()}')
|
|
|
- AND time < toDateTime('${(0, dayjs_1.default)(yesterdayEnd).toISOString()}')
|
|
|
+ AND time >= toDateTime('${yesterdayStartString}')
|
|
|
+ AND time < toDateTime('${yesterdayEndString}')
|
|
|
GROUP BY res
|
|
|
HAVING res IS NOT NULL
|
|
|
`;
|
|
|
@@ -61,8 +64,8 @@ async function run() {
|
|
|
count(DISTINCT uid) AS unique_dones
|
|
|
FROM ${CLICKHOUSE_EVENTS_TABLE}
|
|
|
WHERE event = 'color_done'
|
|
|
- AND time >= toDateTime('${(0, dayjs_1.default)(yesterdayStart).toISOString()}')
|
|
|
- AND time < toDateTime('${(0, dayjs_1.default)(yesterdayEnd).toISOString()}')
|
|
|
+ AND time >= toDateTime('${yesterdayStartString}')
|
|
|
+ AND time < toDateTime('${yesterdayEndString}')
|
|
|
GROUP BY res
|
|
|
HAVING res IS NOT NULL
|
|
|
`;
|