/* Copyright © 2023 Philipp Wolfer Scotty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Scotty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Scotty. If not, see . */ package backends import ( "time" "go.uploadedlobster.com/scotty/internal/models" ) type ExportProcessor[T models.ListensResult | models.LovesResult] interface { ExportBackend() models.Backend Process(oldestTimestamp time.Time, results chan T, progress chan models.Progress) } type ListensExportProcessor struct { Backend models.ListensExport } func (p ListensExportProcessor) ExportBackend() models.Backend { return p.Backend } func (p ListensExportProcessor) Process(oldestTimestamp time.Time, results chan models.ListensResult, progress chan models.Progress) { p.Backend.ExportListens(oldestTimestamp, results, progress) close(progress) } type LovesExportProcessor struct { Backend models.LovesExport } func (p LovesExportProcessor) ExportBackend() models.Backend { return p.Backend } func (p LovesExportProcessor) Process(oldestTimestamp time.Time, results chan models.LovesResult, progress chan models.Progress) { p.Backend.ExportLoves(oldestTimestamp, results, progress) close(progress) }