update: author_info in classification
This commit is contained in:
parent
ecb44b9cba
commit
5b0e27465b
@ -1,6 +1,6 @@
|
|||||||
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 { AllDataType } from "lib/db/schema.d.ts";
|
import {AllDataType, BiliUserType} from "lib/db/schema.d.ts";
|
||||||
import { modelVersion } from "lib/ml/filter_inference.ts";
|
import {modelVersion} from "lib/ml/filter_inference.ts";
|
||||||
|
|
||||||
export async function videoExistsInAllData(client: Client, aid: number) {
|
export async function videoExistsInAllData(client: Client, aid: number) {
|
||||||
return await client.queryObject<{ exists: boolean }>(`SELECT EXISTS(SELECT 1 FROM all_data WHERE aid = $1)`, [aid])
|
return await client.queryObject<{ exists: boolean }>(`SELECT EXISTS(SELECT 1 FROM all_data WHERE aid = $1)`, [aid])
|
||||||
@ -30,5 +30,16 @@ export async function getVideoInfoFromAllData(client: Client, aid: number) {
|
|||||||
`SELECT * FROM all_data WHERE aid = $1`,
|
`SELECT * FROM all_data WHERE aid = $1`,
|
||||||
[aid],
|
[aid],
|
||||||
);
|
);
|
||||||
return queryResult.rows[0];
|
const row = queryResult.rows[0];
|
||||||
|
const q = await client.queryObject<BiliUserType>(
|
||||||
|
`SELECT * FROM bili_user WHERE uid = $1`,
|
||||||
|
[row.uid],
|
||||||
|
)
|
||||||
|
const userRow = q.rows[0];
|
||||||
|
return {
|
||||||
|
title: row.title,
|
||||||
|
description: row.description,
|
||||||
|
tags: row.tags,
|
||||||
|
author_info: userRow.desc
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
11
lib/db/schema.d.ts
vendored
11
lib/db/schema.d.ts
vendored
@ -1,4 +1,5 @@
|
|||||||
export interface AllDataType {
|
export interface AllDataType {
|
||||||
|
id: number;
|
||||||
aid: number;
|
aid: number;
|
||||||
bvid: string | null;
|
bvid: string | null;
|
||||||
description: string | null;
|
description: string | null;
|
||||||
@ -6,4 +7,14 @@ export interface AllDataType {
|
|||||||
tags: string | null;
|
tags: string | null;
|
||||||
title: string | null;
|
title: string | null;
|
||||||
published_at: string | null;
|
published_at: string | null;
|
||||||
|
duration: number;
|
||||||
|
created_at: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BiliUserType {
|
||||||
|
id: number;
|
||||||
|
uid: number;
|
||||||
|
username: string;
|
||||||
|
desc: string;
|
||||||
|
fans: number;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ export const classifyVideoWorker = async (job: Job) => {
|
|||||||
const title = videoInfo.title?.trim() || "untitled";
|
const title = videoInfo.title?.trim() || "untitled";
|
||||||
const description = videoInfo.description?.trim() || "N/A";
|
const description = videoInfo.description?.trim() || "N/A";
|
||||||
const tags = videoInfo.tags?.trim() || "empty";
|
const tags = videoInfo.tags?.trim() || "empty";
|
||||||
const authorInfo = "No";
|
const authorInfo = videoInfo.author_info;
|
||||||
const label = await classifyVideo(title, description, tags, authorInfo, aid);
|
const label = await classifyVideo(title, description, tags, authorInfo, aid);
|
||||||
if (label == -1) {
|
if (label == -1) {
|
||||||
logger.warn(`Failed to classify video ${aid}`, "ml");
|
logger.warn(`Failed to classify video ${aid}`, "ml");
|
||||||
|
@ -35,6 +35,12 @@ export async function insertVideoInfo(client: Client, aid: number) {
|
|||||||
[uid, data.View.owner.name, data.Card.card.sign, data.Card.follower],
|
[uid, data.View.owner.name, data.Card.card.sign, data.Card.follower],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
await client.queryObject(
|
||||||
|
`UPDATE bili_user SET fans = $1 WHERE uid = $2`,
|
||||||
|
[data.Card.follower, uid],
|
||||||
|
);
|
||||||
|
}
|
||||||
logger.log(`Inserted video metadata for aid: ${aid}`, "mq");
|
logger.log(`Inserted video metadata for aid: ${aid}`, "mq");
|
||||||
await ClassifyVideoQueue.add("classifyVideo", { aid });
|
await ClassifyVideoQueue.add("classifyVideo", { aid });
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user