changes on agent
This commit is contained in:
56
services/catalogueUploadService.go
Normal file
56
services/catalogueUploadService.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"nearle/models"
|
||||
"nearle/repositories"
|
||||
)
|
||||
|
||||
// CatalogueUploadService keeps the record of what was sent to the ingest
|
||||
// service, for which shop, and what became of it.
|
||||
//
|
||||
// Deliberately thin. There is no business rule here yet and inventing one would
|
||||
// be the wrong move: the ingest service is the authority on a drop's progress,
|
||||
// and Fiesta's job is to remember the id long enough for somebody to ask it.
|
||||
//
|
||||
// In particular this service does NOT call the ingest service itself. It could,
|
||||
// and it should not: their host is a single CPU-bound container that spends
|
||||
// minutes per batch on image search, and pointing a Go backend's retry loop at
|
||||
// it would turn our uptime into theirs. The browser already polls anonymously —
|
||||
// the batch id is the credential — so the reading happens where the person
|
||||
// waiting for it is, and Fiesta stores what that reading found.
|
||||
type CatalogueUploadService interface {
|
||||
Record(upload *models.CatalogueUpload) error
|
||||
List(tenantID, locationID, pageNo, pageSize int) ([]models.CatalogueUpload, error)
|
||||
UpdateStatus(upload *models.CatalogueUpload) error
|
||||
MarkShelved(batchID string, shelved, skipped int) error
|
||||
}
|
||||
|
||||
type catalogueUploadService struct {
|
||||
repo repositories.CatalogueUploadRepository
|
||||
}
|
||||
|
||||
func NewCatalogueUploadService(repo repositories.CatalogueUploadRepository) CatalogueUploadService {
|
||||
return &catalogueUploadService{repo: repo}
|
||||
}
|
||||
|
||||
func (s *catalogueUploadService) Record(upload *models.CatalogueUpload) error {
|
||||
if upload.Laststatus == "" {
|
||||
// The service's own first answer for an accepted drop. Not "queued":
|
||||
// nothing runs on arrival, and a receipt that said queued would claim
|
||||
// the pipeline had it when it is in fact waiting for a person.
|
||||
upload.Laststatus = "pending"
|
||||
}
|
||||
return s.repo.Record(upload)
|
||||
}
|
||||
|
||||
func (s *catalogueUploadService) List(tenantID, locationID, pageNo, pageSize int) ([]models.CatalogueUpload, error) {
|
||||
return s.repo.List(tenantID, locationID, pageNo, pageSize)
|
||||
}
|
||||
|
||||
func (s *catalogueUploadService) UpdateStatus(upload *models.CatalogueUpload) error {
|
||||
return s.repo.UpdateStatus(upload)
|
||||
}
|
||||
|
||||
func (s *catalogueUploadService) MarkShelved(batchID string, shelved, skipped int) error {
|
||||
return s.repo.MarkShelved(batchID, shelved, skipped)
|
||||
}
|
||||
Reference in New Issue
Block a user