Reduced code redundancy in import processing

This commit is contained in:
Philipp Wolfer 2023-12-03 16:56:32 +01:00
parent ca3b8492b0
commit a87686af57
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
4 changed files with 133 additions and 116 deletions

View file

@ -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()

View file

@ -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()