Skip to content

Conversation

@madrays
Copy link

@madrays madrays commented Nov 1, 2025

问题描述

当站点关闭后,最后一次获取到的数据都是错误的0,而且最后一次的历史记录始终无法删除,导致用户无法使用最后一次站点正常时获取的数据留作纪念。

具体表现为:

  • 站点标记为已离线后,最后一次获取的数据都是0(错误数据)
  • 删除按钮被禁用,无法删除当天的错误数据
  • 删除历史记录后,metadata.lastUserInfo 缓存未更新,仍显示已删除的数据

修复方案

1. 允许删除离线站点的错误数据

  • 当站点标记为已离线(isOffline)时,允许删除当天获取的错误数据
  • 错误数据判断:上传量、下载量、做种数、做种体积、魔力值全部为0
  • 修改 HistoryDataViewDialog.vue 的删除权限判断逻辑

2. 修复删除后缓存未更新的问题

  • 修改 userInfo.ts 中的 removeSiteUserInfo 处理函数
  • 删除历史记录时,同步检查并更新 metadata.lastUserInfo 缓存
  • 如果删除的是最后一次成功数据,则从剩余历史记录中查找最新的成功数据更新缓存
  • 如果所有历史记录都被删除,则清除该站点在 metadata.lastUserInfo 中的缓存

3. 清理调试日志

  • 移除 UserDataTimeline/Index.vue 中的 console.debug 调试日志

修改文件

  • src/entries/options/views/Overview/MyData/HistoryDataViewDialog.vue
  • src/entries/offscreen/utils/userInfo.ts
  • src/entries/options/views/Overview/MyData/UserDataTimeline/Index.vue

测试

已测试验证:

  • 离线站点可以删除当天的错误数据
  • 删除后历史记录正确更新,不再显示已删除的数据
  • metadata.lastUserInfo 缓存正确同步更新

Summary by Sourcery

Allow users to delete zeroed data entries for offline sites, ensure lastUserInfo cache stays in sync after deletions, and improve the Haidan site metadata parsing pipeline while cleaning up debug logs.

New Features:

  • Enhance Haidan site metadata to fetch and parse seeding count and total size via AJAX with deduplication

Bug Fixes:

  • Allow deletion of today’s erroneous data for offline sites by adjusting permission logic in the history dialog
  • Synchronize metadata.lastUserInfo cache after history record removal to prevent stale data

Enhancements:

  • Update Haidan site URL to use HTTPS and refine parsing filters
  • Remove debug logging from the user data timeline component

- Fix seeding quantity: Count deduplicated table rows instead of reading incorrect 588
- Fix seeding size: Add deduplication when accumulating torrent sizes
- Use torrent ID (details.php?id=XXX) as unique identifier for deduplication
- Resolve issue where haidan site returns 100% duplicated data in HTML fragment
- When site is marked as offline, allow deleting today data with all zeros

- Fix metadata.lastUserInfo cache not updating after deletion

- Remove debug console.log from UserDataTimeline
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 1, 2025

Reviewer's Guide

This PR refines the offline-site data deletion workflow by introducing checks to allow removal of same-day erroneous entries, synchronizes the metadata cache upon deletions, cleans up a stray debug statement, and extends the haidan site definition to fetch and parse seeding statistics via AJAX.

Sequence diagram for deleting erroneous data from offline sites

sequenceDiagram
  actor User
  participant "HistoryDataViewDialog.vue"
  participant "userInfo.ts (offscreen)"
  participant "metadataStore"
  User->>"HistoryDataViewDialog.vue": Click delete on today's erroneous data
  "HistoryDataViewDialog.vue"->>"userInfo.ts (offscreen)": sendMessage("removeSiteUserInfo", {siteId, date})
  "userInfo.ts (offscreen)"->>"metadataStore": Remove userInfo for given date
  "userInfo.ts (offscreen)"->>"metadataStore": Check if deleted date is lastUserInfo
  alt Last successful data deleted
    "userInfo.ts (offscreen)"->>"metadataStore": Update lastUserInfo to latest success or remove
  end
  "userInfo.ts (offscreen)"-->>"HistoryDataViewDialog.vue": Deletion complete
  "HistoryDataViewDialog.vue"->>User: Refresh history data
Loading

Class diagram for updated deletion logic and metadata synchronization

classDiagram
  class HistoryDataViewDialog {
    +isSiteOffline: computed
    +isDataErroneous(userInfo: IShowUserInfo): boolean
    +canDeleteTodayData(item: IShowUserInfo): boolean
    +deleteSiteUserInfo(date: string[]): void
  }
  class userInfo {
    +removeSiteUserInfo(siteId: string, date: string[]): void
  }
  class metadataStore {
    +lastUserInfo: Record<TSiteID, IUserInfo>
  }
  HistoryDataViewDialog --> userInfo : sendMessage("removeSiteUserInfo")
  userInfo --> metadataStore : update lastUserInfo on deletion
Loading

Class diagram for haidan site definition AJAX seeding info parsing

classDiagram
  class siteMetadata {
    +process: Step[]
  }
  class Step {
    +requestConfig: object
    +fields: string[]
    +selectors: object
  }
  siteMetadata "1" o-- "*" Step : process steps
  Step <|-- SeedingStep : AJAX seeding info
  class SeedingStep {
    +selectors: object
    +seeding
    +seedingSize
  }
Loading

File-Level Changes

Change Details Files
Enable deletion of erroneous same-day data for offline sites
  • Add computed isSiteOffline and functions isDataErroneous/canDeleteTodayData
  • Filter deletion dates in deleteSiteUserInfo based on new checks
  • Bind delete button disabled state to canDeleteTodayData
src/entries/options/views/Overview/MyData/HistoryDataViewDialog.vue
Synchronize metadata.lastUserInfo after removals
  • Fetch and inspect metadata cache in removeSiteUserInfo handler
  • Recompute or clear lastUserInfo based on remaining history entries
  • Persist updated metadata via setExtStorage
src/entries/offscreen/utils/userInfo.ts
Remove leftover debug log
  • Eliminate console.debug in timeline component
src/entries/options/views/Overview/MyData/UserDataTimeline/Index.vue
Augment haidan site metadata to parse seeding data
  • Correct URL and regex cleanup in metadata schema
  • Import filesize utilities, Sizzle and HTML parser
  • Define placeholder seeding fields and add multi-step AJAX process
  • Implement filters to count torrents and sum sizes from HTML fragment
src/packages/site/definitions/haidan.ts

Possibly linked issues

  • #N/A: The PR allows deleting erroneous data from offline sites and correctly updates the lastUserInfo cache after deletion, which directly addresses the issue of completely removing data for dead sites.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant