mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-25 13:57:56 +02:00
Implemented progressbar for export/import
This commit is contained in:
parent
ab04eb1123
commit
6e330daf06
24 changed files with 590 additions and 239 deletions
|
@ -105,13 +105,14 @@ func (l LovesList) Swap(i, j int) {
|
|||
}
|
||||
|
||||
type ListensResult struct {
|
||||
Error error
|
||||
Listens ListensList
|
||||
Listens ListensList
|
||||
OldestTimestamp time.Time
|
||||
Error error
|
||||
}
|
||||
|
||||
type LovesResult struct {
|
||||
Error error
|
||||
Loves LovesList
|
||||
Error error
|
||||
}
|
||||
|
||||
type ImportResult struct {
|
||||
|
@ -119,6 +120,9 @@ type ImportResult struct {
|
|||
ImportCount int
|
||||
LastTimestamp time.Time
|
||||
ImportErrors []string
|
||||
|
||||
// Error is only set if an unrecoverable import error occurred
|
||||
Error error
|
||||
}
|
||||
|
||||
// Sets LastTimestamp to newTime, if newTime is newer than LastTimestamp
|
||||
|
@ -127,3 +131,27 @@ func (i *ImportResult) UpdateTimestamp(newTime time.Time) {
|
|||
i.LastTimestamp = newTime
|
||||
}
|
||||
}
|
||||
|
||||
func (i *ImportResult) Update(from ImportResult) {
|
||||
i.TotalCount = from.TotalCount
|
||||
i.ImportCount += from.ImportCount
|
||||
i.UpdateTimestamp(from.LastTimestamp)
|
||||
}
|
||||
|
||||
type Progress struct {
|
||||
Total int64
|
||||
Elapsed int64
|
||||
Completed bool
|
||||
}
|
||||
|
||||
func (p Progress) FromImportResult(result ImportResult) Progress {
|
||||
p.Total = int64(result.TotalCount)
|
||||
p.Elapsed = int64(result.ImportCount)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p Progress) Complete() Progress {
|
||||
p.Total = p.Elapsed
|
||||
p.Completed = true
|
||||
return p
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue