mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-25 05:47:57 +02:00
Reduced code redundancy in import processing
This commit is contained in:
parent
ca3b8492b0
commit
a87686af57
4 changed files with 133 additions and 116 deletions
|
@ -70,12 +70,15 @@ var listensCmd = &cobra.Command{
|
|||
progress := progressBar(&wg, exportProgress, importProgress)
|
||||
|
||||
// Export from source
|
||||
listensChan := make(chan models.ListensResult, 1000)
|
||||
go exportBackend.ExportListens(timestamp, listensChan, exportProgress)
|
||||
exportChan := make(chan models.ListensResult, 1000)
|
||||
go exportBackend.ExportListens(timestamp, exportChan, exportProgress)
|
||||
|
||||
// Import into target
|
||||
resultChan := make(chan models.ImportResult)
|
||||
go backends.ProcessListensImports(importBackend, listensChan, resultChan, importProgress)
|
||||
var processor = backends.ListensImportProcessor{
|
||||
Backend: importBackend,
|
||||
}
|
||||
go processor.Process(exportChan, resultChan, importProgress)
|
||||
result := <-resultChan
|
||||
close(exportProgress)
|
||||
wg.Wait()
|
||||
|
|
|
@ -70,12 +70,15 @@ var lovesCmd = &cobra.Command{
|
|||
progress := progressBar(&wg, exportProgress, importProgress)
|
||||
|
||||
// Export from source
|
||||
lovesChan := make(chan models.LovesResult, 1000)
|
||||
go exportBackend.ExportLoves(timestamp, lovesChan, exportProgress)
|
||||
exportChan := make(chan models.LovesResult, 1000)
|
||||
go exportBackend.ExportLoves(timestamp, exportChan, exportProgress)
|
||||
|
||||
// Import into target
|
||||
resultChan := make(chan models.ImportResult)
|
||||
go backends.ProcessLovesImports(importBackend, lovesChan, resultChan, importProgress)
|
||||
var processor = backends.LovesImportProcessor{
|
||||
Backend: importBackend,
|
||||
}
|
||||
go processor.Process(exportChan, resultChan, importProgress)
|
||||
result := <-resultChan
|
||||
close(exportProgress)
|
||||
wg.Wait()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue