Skip to content

fix: 显示错误站点的历史数据并添加视觉错误指示器#743

Open
madrays wants to merge 3 commits intopt-plugins:masterfrom
madrays:fix/error-status-display-and-sort
Open

fix: 显示错误站点的历史数据并添加视觉错误指示器#743
madrays wants to merge 3 commits intopt-plugins:masterfrom
madrays:fix/error-status-display-and-sort

Conversation

@madrays
Copy link
Copy Markdown

@madrays madrays commented Nov 1, 2025

此 PR 在 fix: 允许删除离线站点当天获取的错误数据 的基础上,进一步改进了错误站点的显示逻辑:

主要改进

  1. 错误状态显示历史数据:当站点报错或获取到空数据时,系统会从历史记录中查找最后一次有效的非空数据并显示,而不是显示空白。

  2. 更新时间双重显示

    • 显示具体的错误信息(通过 ResultParseStatus 组件)
    • 同时显示历史有效数据的更新时间(如果有)
  3. 空数据智能判断

    • 只有当历史中存在非空数据时,当前的空数据才会被标记为错误
    • 如果历史数据本身都是空的,则保持原状态(可能站点本身就没有这些数据)
  4. 错误状态置顶显示

    • 通过 sortPriority 字段,确保错误状态和空数据状态的站点始终置顶显示
    • 使用 computedSortByhandleSortByUpdate 确保排序逻辑正常工作
  5. 视觉错误指示器

    • 站点图标:错误状态的站点图标会红色闪烁(error-blink 动画)
    • 错误芯片:更新时间列的错误状态芯片也会红色闪烁(error-blink-chip 动画)

技术细节

  • 添加了 isEmptyUserInfo 函数来检测用户数据是否为空
  • 引入了 historyUpdateAtsortPriority 字段到 IUserInfoItem 接口
  • updateTableData 中实现了历史数据查找和优先级计算逻辑
  • 添加了 CSS 动画样式来实现红色闪烁效果

这些改进确保了用户在遇到站点错误时能够:

  • 看到最后有效的数据记录(而不是空白)
  • 通过视觉提示快速识别问题站点
  • 方便地找到并处理错误站点(置顶显示)

Summary by Sourcery

Improve MyData display by showing historical user info when fetch errors or returns empty, adding dual update timestamps and blinking error indicators, ensuring faulty sites sort to the top, refining history deletion logic and metadata updates, and extending the Haidan site plugin with AJAX-based seeding data extraction.

New Features:

  • Display last valid non-empty historical data for sites when current fetch fails or returns empty
  • Show both current update time and historical update time in the MyData table
  • Add red blinking animations on site icons and error chips to visually highlight error states
  • Allow deletion of today's history entry for offline sites when the data is detected as erroneous
  • Extend the Haidan site definition to extract seeding count and total seeding size via AJAX

Enhancements:

  • Introduce sortPriority and computedSortBy to keep error or empty-data sites at the top
  • Refine history deletion filter logic and update offscreen metadata.lastUserInfo after removals
  • Remove a debug log in the UserDataTimeline 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
Copy Markdown

@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
Copy Markdown

sourcery-ai Bot commented Nov 1, 2025

Reviewer's Guide

This PR overhauls error site handling by retrieving and displaying the last valid historical data for error or empty responses, prioritizing and visually highlighting these sites, refining deletion permissions and metadata sync, and extending the haidan site parser to fetch seeding stats via AJAX.

Entity relationship diagram for user info and metadata after deletion

erDiagram
    USER_INFO_STORE {
      siteId string
      date string
      userInfo object
    }
    METADATA_STORE {
      lastUserInfo object
    }
    USER_INFO_STORE ||--o{ METADATA_STORE : updates
    USER_INFO_STORE ||--o{ USER_INFO_HISTORY : contains
    USER_INFO_HISTORY {
      date string
      status enum
      userInfo object
    }
    METADATA_STORE ||--o| USER_INFO_HISTORY : syncs with
    USER_INFO_STORE ||--o| USER_INFO_HISTORY : has
Loading

Class diagram for updated IUserInfoItem and related logic

classDiagram
    class IUserInfoItem {
      siteUserConfig: ISiteUserConfig
      historyUpdateAt?: number
      sortPriority?: number
    }
    IUserInfoItem --|> IUserInfo
    class IUserInfo {
      status
      updateAt
      bonus
      levelName
      joinTime
      uploaded
      downloaded
      seeding
      seedingSize
      messageCount
    }
    class ISiteUserConfig {
      isOffline
    }
    class MetadataStore {
      lastUserInfo: Record<TSiteID, IUserInfo>
    }
    class ConfigStore {
      tableBehavior
      updateTableBehavior()
      myDataTableControl
    }
    class TableData {
      value: IUserInfoItem[]
    }
    class isEmptyUserInfo {
      +isEmptyUserInfo(userInfo: Partial<IUserInfo>): boolean
    }
    class updateTableData {
      +updateTableData()
    }
    updateTableData --> isEmptyUserInfo
    updateTableData --> MetadataStore
    updateTableData --> TableData
    updateTableData --> ConfigStore
Loading

File-Level Changes

Change Details Files
Enhanced table data logic to fallback on historical records when current fetch fails or is empty
  • Added isEmptyUserInfo helper
  • Extended IUserInfoItem with historyUpdateAt and sortPriority
  • Updated updateTableData to fetch history, merge last valid data, record historyUpdateAt and adjust status
src/entries/options/views/Overview/MyData/Index.vue
Ensured error or empty-with-history sites always sort to the top
  • Introduced computedSortBy and handleSortByUpdate to prepend sortPriority
  • Computed sortPriority during data assembly
  • Bound DataTable to computedSortBy and custom update handler
src/entries/options/views/Overview/MyData/Index.vue
Added visual error indicators and dual timestamp display
  • Wrapped site icon and status chip with conditional .error-blink classes
  • Inserted CSS animations .error-blink and .error-blink-chip
  • Modified updateAt cell template to show both current and history timestamps
src/entries/options/views/Overview/MyData/Index.vue
Refined history view deletion rules for offline/error data
  • Added isSiteOffline, isDataErroneous and canDeleteTodayData functions
  • Filtered deletion dates to allow removing today’s error items when offline
  • Updated delete button disabled logic and sendMessage payload
src/entries/options/views/Overview/MyData/HistoryDataViewDialog.vue
Synchronized metadata.lastUserInfo when history records are deleted
  • Enhanced removeSiteUserInfo handler to update or clear metadata.lastUserInfo in storage
  • Recomputed lastUserInfo from remaining history when needed
src/entries/offscreen/utils/userInfo.ts
Extended haidan site metadata parsing to accurately fetch seeding stats via AJAX
  • Updated site URL pattern and import utilities
  • Refactored process pipeline into multi-step requests
  • Implemented custom selectors using createDocument, Sizzle, and parseSizeString to count and size seeding entries
src/packages/site/definitions/haidan.ts

Possibly linked issues

  • fix: 显示错误站点的历史数据并添加视觉错误指示器 #743: The PR provides a comprehensive fix for incorrect site data display and inability to retrieve user info by showing historical data, marking errors, and adding visual indicators.
  • #[Issue ID]: PR通过引入新的排序优先级字段,确保错误状态和空数据状态的站点始终置顶显示,修复了站点数据排序错误。

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