update: better task retrieval for snapshotTick
add: logging when snapshot the video
This commit is contained in:
parent
33c63fc29f
commit
9e764746fb
@ -187,9 +187,14 @@ export async function getSnapshotsInNextSecond(client: Client) {
|
|||||||
const query = `
|
const query = `
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM snapshot_schedule
|
FROM snapshot_schedule
|
||||||
WHERE started_at
|
WHERE started_at <= NOW() + INTERVAL '1 seconds' AND status = 'pending'
|
||||||
BETWEEN NOW() - INTERVAL '5 seconds'
|
ORDER BY
|
||||||
AND NOW() + INTERVAL '1 seconds'
|
CASE
|
||||||
|
WHEN type = 'milestone' THEN 0
|
||||||
|
ELSE 1
|
||||||
|
END,
|
||||||
|
started_at
|
||||||
|
LIMIT 3;
|
||||||
`;
|
`;
|
||||||
const res = await client.queryObject<SnapshotScheduleType>(query, []);
|
const res = await client.queryObject<SnapshotScheduleType>(query, []);
|
||||||
return res.rows;
|
return res.rows;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Client } from "https://deno.land/x/postgres@v0.19.3/mod.ts";
|
import { Client } from "https://deno.land/x/postgres@v0.19.3/mod.ts";
|
||||||
import { getVideoInfo } from "lib/net/getVideoInfo.ts";
|
import { getVideoInfo } from "lib/net/getVideoInfo.ts";
|
||||||
import { LatestSnapshotType } from "lib/db/schema.d.ts";
|
import { LatestSnapshotType } from "lib/db/schema.d.ts";
|
||||||
|
import logger from "lib/log/logger.ts";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch video stats from bilibili API and insert into database
|
* Fetch video stats from bilibili API and insert into database
|
||||||
@ -39,6 +40,8 @@ export async function insertVideoSnapshot(
|
|||||||
[aid, views, danmakus, replies, likes, coins, shares, favorites],
|
[aid, views, danmakus, replies, likes, coins, shares, favorites],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
logger.log(`Taken snapshot for video ${aid}.`, "net", "fn:insertVideoSnapshot");
|
||||||
|
|
||||||
const snapshot: LatestSnapshotType = {
|
const snapshot: LatestSnapshotType = {
|
||||||
aid,
|
aid,
|
||||||
views,
|
views,
|
||||||
|
Loading…
Reference in New Issue
Block a user