Compare commits
5 Commits
39acac09e7
...
b2edaf8fc4
Author | SHA1 | Date | |
---|---|---|---|
b2edaf8fc4 | |||
da8b2d3b4d | |||
64a7f13da7 | |||
19d7276280 | |||
106049bfc6 |
@ -109,7 +109,7 @@ const log = (value: number, base: number = 10) => Math.log(value) / Math.log(bas
|
|||||||
* @param aid - aid of the video
|
* @param aid - aid of the video
|
||||||
* @returns ETA in hours
|
* @returns ETA in hours
|
||||||
*/
|
*/
|
||||||
const getAdjustedShortTermETA = async (client: Client, aid: number) => {
|
export const getAdjustedShortTermETA = async (client: Client, aid: number) => {
|
||||||
const latestSnapshot = await getLatestSnapshot(client, aid);
|
const latestSnapshot = await getLatestSnapshot(client, aid);
|
||||||
// Immediately dispatch a snapshot if there is no snapshot yet
|
// Immediately dispatch a snapshot if there is no snapshot yet
|
||||||
if (!latestSnapshot) return 0;
|
if (!latestSnapshot) return 0;
|
||||||
@ -117,7 +117,7 @@ const getAdjustedShortTermETA = async (client: Client, aid: number) => {
|
|||||||
if (!snapshotsEnough) return 0;
|
if (!snapshotsEnough) return 0;
|
||||||
|
|
||||||
const currentTimestamp = new Date().getTime();
|
const currentTimestamp = new Date().getTime();
|
||||||
const timeIntervals = [3 * MINUTE, 20 * MINUTE, 1 * HOUR, 3 * HOUR, 6 * HOUR];
|
const timeIntervals = [3 * MINUTE, 20 * MINUTE, 1 * HOUR, 3 * HOUR, 6 * HOUR, 72 * HOUR];
|
||||||
const DELTA = 0.00001;
|
const DELTA = 0.00001;
|
||||||
let minETAHours = Infinity;
|
let minETAHours = Infinity;
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ export const scheduleCleanupWorker = async (_job: Job) => {
|
|||||||
SELECT id, aid, type
|
SELECT id, aid, type
|
||||||
FROM snapshot_schedule
|
FROM snapshot_schedule
|
||||||
WHERE status IN ('pending', 'processing')
|
WHERE status IN ('pending', 'processing')
|
||||||
AND started_at < NOW() - INTERVAL '5 minutes'
|
AND started_at < NOW() - INTERVAL '30 minutes'
|
||||||
`;
|
`;
|
||||||
const { rows } = await client.queryObject<{ id: bigint; aid: bigint; type: string }>(query);
|
const { rows } = await client.queryObject<{ id: bigint; aid: bigint; type: string }>(query);
|
||||||
if (rows.length === 0) return;
|
if (rows.length === 0) return;
|
||||||
|
@ -24,10 +24,11 @@ export async function insertVideoInfo(client: Client, aid: number) {
|
|||||||
const title = data.View.title;
|
const title = data.View.title;
|
||||||
const published_at = formatTimestampToPsql(data.View.pubdate * SECOND + 8 * HOUR);
|
const published_at = formatTimestampToPsql(data.View.pubdate * SECOND + 8 * HOUR);
|
||||||
const duration = data.View.duration;
|
const duration = data.View.duration;
|
||||||
|
const cover = data.View.pic;
|
||||||
await client.queryObject(
|
await client.queryObject(
|
||||||
`INSERT INTO bilibili_metadata (aid, bvid, description, uid, tags, title, published_at, duration)
|
`INSERT INTO bilibili_metadata (aid, bvid, description, uid, tags, title, published_at, duration, cover_url)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)`,
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
|
||||||
[aid, bvid, desc, uid, tags, title, published_at, duration],
|
[aid, bvid, desc, uid, tags, title, published_at, duration, cover],
|
||||||
);
|
);
|
||||||
const userExists = await userExistsInBiliUsers(client, aid);
|
const userExists = await userExistsInBiliUsers(client, aid);
|
||||||
if (!userExists) {
|
if (!userExists) {
|
||||||
|
Loading…
Reference in New Issue
Block a user