feat: 完善视频任务与 KOC 资源库
This commit is contained in:
@@ -94,6 +94,8 @@ export async function ensureSchema(database?: DatabaseClient) {
|
||||
due_at TEXT NOT NULL,
|
||||
status TEXT NOT NULL DEFAULT 'active',
|
||||
task_type TEXT NOT NULL DEFAULT 'content_publish',
|
||||
platform TEXT NOT NULL DEFAULT '小红书',
|
||||
content_format TEXT NOT NULL DEFAULT 'image_text',
|
||||
source_url TEXT NOT NULL DEFAULT '',
|
||||
source_sheet_id TEXT NOT NULL DEFAULT '',
|
||||
source_sheet_name TEXT NOT NULL DEFAULT '',
|
||||
@@ -110,6 +112,7 @@ export async function ensureSchema(database?: DatabaseClient) {
|
||||
title TEXT NOT NULL,
|
||||
body TEXT NOT NULL DEFAULT '',
|
||||
image_assets TEXT NOT NULL DEFAULT '[]',
|
||||
video_assets TEXT NOT NULL DEFAULT '[]',
|
||||
status TEXT NOT NULL DEFAULT 'available',
|
||||
source TEXT NOT NULL DEFAULT '飞书内容表',
|
||||
source_row INTEGER,
|
||||
@@ -124,9 +127,13 @@ export async function ensureSchema(database?: DatabaseClient) {
|
||||
profile_url TEXT NOT NULL DEFAULT '',
|
||||
ip_location TEXT NOT NULL DEFAULT '待识别',
|
||||
followers INTEGER NOT NULL DEFAULT 0,
|
||||
gender TEXT NOT NULL DEFAULT '',
|
||||
bio TEXT NOT NULL DEFAULT '',
|
||||
tags TEXT NOT NULL DEFAULT '',
|
||||
post_count INTEGER NOT NULL DEFAULT 0,
|
||||
avg_views INTEGER NOT NULL DEFAULT 0,
|
||||
cooperation_source TEXT NOT NULL DEFAULT '',
|
||||
current_contact TEXT NOT NULL DEFAULT '',
|
||||
first_seen_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_seen_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
)`,
|
||||
@@ -185,6 +192,7 @@ export async function ensureSchema(database?: DatabaseClient) {
|
||||
latest_likes INTEGER,
|
||||
latest_comments INTEGER,
|
||||
latest_collects INTEGER,
|
||||
latest_shares INTEGER,
|
||||
collection_status TEXT NOT NULL DEFAULT 'pending',
|
||||
collection_status_description TEXT,
|
||||
collection_updated_at TEXT,
|
||||
@@ -202,6 +210,7 @@ export async function ensureSchema(database?: DatabaseClient) {
|
||||
likes INTEGER,
|
||||
comments INTEGER,
|
||||
collects INTEGER,
|
||||
shares INTEGER,
|
||||
status_description TEXT,
|
||||
started_at TEXT,
|
||||
completed_at TEXT,
|
||||
@@ -293,6 +302,14 @@ export async function ensureSchema(database?: DatabaseClient) {
|
||||
"public_account_id",
|
||||
"public_account_id TEXT NOT NULL DEFAULT ''",
|
||||
);
|
||||
await ensureColumn("accounts", "gender", "gender TEXT NOT NULL DEFAULT ''");
|
||||
await ensureColumn("accounts", "bio", "bio TEXT NOT NULL DEFAULT ''");
|
||||
await ensureColumn("accounts", "tags", "tags TEXT NOT NULL DEFAULT ''");
|
||||
await ensureColumn(
|
||||
"accounts",
|
||||
"current_contact",
|
||||
"current_contact TEXT NOT NULL DEFAULT ''",
|
||||
);
|
||||
await ensureColumn("distributions", "claim_id", "claim_id TEXT");
|
||||
await ensureColumn(
|
||||
"distributions",
|
||||
@@ -796,22 +813,44 @@ export async function getDashboardData() {
|
||||
await Promise.all([
|
||||
db.prepare("SELECT * FROM partners ORDER BY created_at DESC").all(),
|
||||
db.prepare("SELECT * FROM tasks ORDER BY created_at DESC").all(),
|
||||
db.prepare("SELECT * FROM accounts ORDER BY last_seen_at DESC").all(),
|
||||
db
|
||||
.prepare(
|
||||
`SELECT
|
||||
a.*,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT d.publish_url
|
||||
FROM distributions d
|
||||
WHERE d.account_id = a.id
|
||||
AND TRIM(COALESCE(d.publish_url, '')) != ''
|
||||
ORDER BY d.updated_at DESC, d.claimed_at DESC
|
||||
LIMIT 1
|
||||
),
|
||||
''
|
||||
) AS latest_publish_url
|
||||
FROM accounts a
|
||||
ORDER BY a.last_seen_at DESC`,
|
||||
)
|
||||
.all(),
|
||||
db
|
||||
.prepare(
|
||||
`SELECT
|
||||
d.*,
|
||||
c.title AS content_title,
|
||||
p.name AS partner_name,
|
||||
cl.claimant_name AS claimant_name,
|
||||
a.nickname AS account_nickname,
|
||||
a.platform AS account_platform,
|
||||
t.name AS task_name,
|
||||
t.brand AS task_brand,
|
||||
t.task_type AS task_type,
|
||||
t.platform AS task_platform,
|
||||
t.content_format AS content_format,
|
||||
t.due_at AS due_at
|
||||
FROM distributions d
|
||||
JOIN contents c ON c.id = d.content_id
|
||||
JOIN partners p ON p.id = d.partner_id
|
||||
LEFT JOIN claims cl ON cl.id = d.claim_id
|
||||
JOIN tasks t ON t.id = d.task_id
|
||||
LEFT JOIN accounts a ON a.id = d.account_id
|
||||
ORDER BY d.updated_at DESC, d.claimed_at DESC`,
|
||||
|
||||
Reference in New Issue
Block a user