64 lines
1.8 KiB
Markdown
64 lines
1.8 KiB
Markdown
# Market Backend Metrics CSV Design
|
|
|
|
## Goal
|
|
|
|
Extend the existing CSV export so it includes the six backend metrics already shown in the plugin UI.
|
|
|
|
## Confirmed Decisions
|
|
|
|
- Reuse the current export flow.
|
|
- Do not add a separate backend request for CSV export.
|
|
- Read backend metrics directly from the in-memory `MarketRecord`.
|
|
- Append the six backend metrics columns after the existing CSV columns.
|
|
- Keep the existing CSV columns and ordering unchanged.
|
|
- Use these exact CSV headers:
|
|
- `看后搜率`
|
|
- `看后搜数`
|
|
- `新增A3数`
|
|
- `新增A3率`
|
|
- `CPA3`
|
|
- `cp_search`
|
|
- If a record has no backend metrics, export empty strings for these six columns.
|
|
|
|
## Architecture
|
|
|
|
- `src/content/market/csv-exporter.ts` remains the single place that defines CSV column layout.
|
|
- The exporter will keep current base columns and Xingtu rate columns, then append six backend metrics columns.
|
|
- No UI changes.
|
|
- No batch submission changes.
|
|
- No popup or config changes.
|
|
|
|
## Data Source
|
|
|
|
Each exported row will read from:
|
|
|
|
- existing fields:
|
|
- `authorId`
|
|
- `authorName`
|
|
- `location`
|
|
- `price21To60s`
|
|
- `rates.singleVideoAfterSearchRate`
|
|
- `rates.personalVideoAfterSearchRate`
|
|
- new backend metrics fields:
|
|
- `backendMetrics.afterViewSearchRate`
|
|
- `backendMetrics.afterViewSearchCount`
|
|
- `backendMetrics.a3IncreaseCount`
|
|
- `backendMetrics.newA3Rate`
|
|
- `backendMetrics.cpa3`
|
|
- `backendMetrics.cpSearch`
|
|
|
|
## Failure Handling
|
|
|
|
- Missing backend metrics: export blank cells
|
|
- Existing rate formatting behavior remains unchanged
|
|
- Backend loading state does not alter CSV structure; it only affects whether the cells contain values or blanks
|
|
|
|
## Testing
|
|
|
|
Add tests for:
|
|
|
|
- backend metric headers appended to CSV
|
|
- backend metric values exported correctly
|
|
- empty backend metric cells when metrics are absent
|
|
- no regression in current base/rate export behavior
|