mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-12 07:10:44 +08:00
修复最近转存文件只包含日期信息时集数统计和转存进度丢失的问题
- 修复后端 enrich_tasks_with_calendar_meta 函数,增加对只有日期情况的处理 - 修复前端任务列表页面数据加载,确保 episodes 数据和进度映射正确构建 - 解决刷新页面后已转存集数变为0的问题 - 保持向后兼容,不影响包含集数的文件处理 问题:最近转存文件中不包含集数但包含播出日期时,任务列表页面的集数统计和转存进度在刷新后会丢失 解决:完善后端数据处理逻辑,确保前端页面能正确加载和构建所需的数据映射
This commit is contained in:
parent
7c1d0f9fc1
commit
41b2cd7727
26
app/run.py
26
app/run.py
@ -76,7 +76,7 @@ def enrich_tasks_with_calendar_meta(tasks_info: list) -> list:
|
||||
for tid, sn, sname, ecount in rows:
|
||||
season_meta[(int(tid), int(sn))] = {'season_name': sname or '', 'episode_count': int(ecount or 0)}
|
||||
|
||||
# 统计“已转存集数”:基于转存记录最新进度构建映射(按任务名)
|
||||
# 统计"已转存集数":基于转存记录最新进度构建映射(按任务名)
|
||||
transferred_by_task = {}
|
||||
try:
|
||||
rdb = RecordDB()
|
||||
@ -115,7 +115,31 @@ def enrich_tasks_with_calendar_meta(tasks_info: list) -> list:
|
||||
processed = process_season_episode_info(name_wo_ext, task_name)
|
||||
parsed = extractor.extract_progress_from_latest_file(processed)
|
||||
if parsed and parsed.get('episode_number'):
|
||||
# 包含集数的情况
|
||||
transferred_by_task[task_name] = int(parsed['episode_number'])
|
||||
elif parsed and parsed.get('air_date'):
|
||||
# 只有日期的情况:通过查询数据库获取对应日期的最大集数
|
||||
air_date = parsed['air_date']
|
||||
try:
|
||||
# 查找该任务对应的节目名称
|
||||
task_info = next((t for t in tasks_info if (t.get('task_name') or t.get('taskname')) == task_name), None)
|
||||
if task_info:
|
||||
show_name = (task_info.get('matched_show_name') or task_info.get('show_name') or '').strip()
|
||||
if show_name:
|
||||
# 查询该节目在该日期播出的最大集数
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT MAX(CAST(episode_number AS INTEGER))
|
||||
FROM episodes
|
||||
WHERE show_name = ? AND air_date = ?
|
||||
""",
|
||||
(show_name, air_date)
|
||||
)
|
||||
result = cur.fetchone()
|
||||
if result and result[0] is not None:
|
||||
transferred_by_task[task_name] = int(result[0])
|
||||
except Exception:
|
||||
pass
|
||||
rdb.close()
|
||||
except Exception:
|
||||
transferred_by_task = {}
|
||||
|
||||
@ -8925,20 +8925,30 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
loadTaskLatestInfo() {
|
||||
async loadTaskLatestInfo() {
|
||||
// 获取所有任务的最新转存信息(包括日期和文件)
|
||||
axios.get('/task_latest_info')
|
||||
.then(response => {
|
||||
if (response.data.success) {
|
||||
this.taskLatestRecords = response.data.data.latest_records;
|
||||
this.taskLatestFiles = response.data.data.latest_files;
|
||||
} else {
|
||||
console.error('获取任务最新信息失败:', response.data.message);
|
||||
try {
|
||||
const response = await axios.get('/task_latest_info');
|
||||
if (response.data.success) {
|
||||
this.taskLatestRecords = response.data.data.latest_records;
|
||||
this.taskLatestFiles = response.data.data.latest_files;
|
||||
|
||||
// 构建进度映射,确保基于日期的集数统计能正常工作
|
||||
this.calendar.progressByTaskName = this.buildProgressByTaskNameFromLatestFiles(this.taskLatestFiles || {});
|
||||
this.calendar.progressByShowName = this.buildProgressByShowNameFromTasks(this.calendar.tasks || [], this.calendar.progressByTaskName);
|
||||
|
||||
// 同时加载 episodes 数据,确保基于日期的集数统计能正常工作
|
||||
try {
|
||||
await this.loadCalendarEpisodesLocal();
|
||||
} catch (e) {
|
||||
console.warn('加载 episodes 数据失败:', e);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('获取任务最新信息失败:', error);
|
||||
});
|
||||
} else {
|
||||
console.error('获取任务最新信息失败:', response.data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取任务最新信息失败:', error);
|
||||
}
|
||||
},
|
||||
// 加载任务列表的元数据信息(用于热更新海报和元数据)
|
||||
async loadTasklistMetadata() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user