Files
ncore-hnr/internal/model/model.go
Zsolt Alföldi 89835b237c Add retry mechanism and failure notifications for nCore/qBittorrent setup
- Implemented a retry mechanism for external calls, allowing up to 3 attempts before failing.
- Enhanced error handling to send failure notifications when setup steps fail, including detailed error messages.
- Updated RunSummary model to include status, error step, and error message fields for better tracking of run outcomes.
- Modified database schema to store failure metadata for runs.
- Updated README.md to reflect changes in error handling and notification behavior.
2026-05-07 12:03:00 +02:00

108 lines
3.6 KiB
Go

package model
import "time"
type Torrent struct {
ID int64 `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Start string `json:"start"`
Updated string `json:"updated"`
Status string `json:"status"`
Uploaded string `json:"uploaded"`
Downloaded string `json:"downloaded"`
Remaining string `json:"remaining"`
Ratio string `json:"ratio"`
HnRMarked bool `json:"hnr_marked"`
QBit *QBitTorrent `json:"qbit,omitempty"`
}
type HitRunPage struct {
Alert string `json:"alert,omitempty"`
Stats map[string]string `json:"stats"`
Torrents []Torrent `json:"torrents"`
}
type QBitTorrent struct {
Hash string `json:"hash"`
Name string `json:"name"`
State string `json:"state"`
Progress float64 `json:"progress"`
Ratio float64 `json:"ratio"`
Uploaded int64 `json:"uploaded"`
Downloaded int64 `json:"downloaded"`
LastActivity int64 `json:"last_activity"`
}
type ActionResult struct {
Torrent Torrent `json:"torrent"`
Matched bool `json:"matched"`
ForceStarted bool `json:"force_started"`
Reannounced bool `json:"reannounced"`
ManualNeeded bool `json:"manual_needed"`
Message string `json:"message,omitempty"`
QBit *QBitTorrent `json:"qbit,omitempty"`
FirstSeenAt time.Time `json:"first_seen_at"`
LastSeenAt time.Time `json:"last_seen_at"`
}
type RunSummary struct {
StartedAt time.Time `json:"started_at"`
Status string `json:"status"`
ErrorStep string `json:"error_step,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
DryRun bool `json:"dry_run"`
TotalRisk int `json:"total_risk"`
Matched int `json:"matched"`
Unmatched int `json:"unmatched"`
ForceStarted int `json:"force_started"`
Reannounced int `json:"reannounced"`
ManualNeeded int `json:"manual_needed"`
Results []ActionResult `json:"results"`
}
type StatusCount struct {
Status string `json:"status"`
Count int `json:"count"`
}
type RunRecord struct {
StartedAt string `json:"started_at"`
Status string `json:"status"`
ErrorStep string `json:"error_step,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
DryRun bool `json:"dry_run"`
TotalRisk int `json:"total_risk"`
Matched int `json:"matched"`
Unmatched int `json:"unmatched"`
ForceStarted int `json:"force_started"`
Reannounced int `json:"reannounced"`
ManualNeeded int `json:"manual_needed"`
}
type TorrentStatus struct {
ID int64 `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
FirstSeenAt string `json:"first_seen_at"`
LastSeenAt string `json:"last_seen_at"`
LastResolvedAt string `json:"last_resolved_at,omitempty"`
HnRMarked bool `json:"hnr_marked"`
QBitName string `json:"qbit_name,omitempty"`
QBitState string `json:"qbit_state,omitempty"`
QBitProgress float64 `json:"qbit_progress,omitempty"`
QBitRatio float64 `json:"qbit_ratio,omitempty"`
LastActionAt string `json:"last_action_at,omitempty"`
ManualNeededAt string `json:"manual_needed_at,omitempty"`
}
type StatsSnapshot struct {
Counts []StatusCount `json:"counts"`
LastRun *RunRecord `json:"last_run,omitempty"`
ManualNeeded []TorrentStatus `json:"manual_needed"`
}
type StatusSnapshot struct {
Torrents []TorrentStatus `json:"torrents"`
}