feat: image variants per image
This commit is contained in:
1 parent
f567866161
commit
951fef18ba
92 files changed
+8695
-413
No files matched your search
@@ -70,6 +70,26 @@ func (v *VariantFileRepository) Delete(id uint32) error {
|
||||
return v.db.Delete(&entity.ImageVariantFile{}, id).Error
|
||||
}
|
||||
|
||||
func (v *VariantFileRepository) TotalsBySource() (map[string]domain.VariantFileTotals, error) {
|
||||
var rows []struct {
|
||||
SourceName string
|
||||
Files int
|
||||
Bytes int64
|
||||
}
|
||||
err := v.db.Model(&entity.ImageVariantFile{}).
|
||||
Select("source_name, COUNT(*) AS files, COALESCE(SUM(size), 0) AS bytes").
|
||||
Group("source_name").
|
||||
Scan(&rows).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
totals := make(map[string]domain.VariantFileTotals, len(rows))
|
||||
for _, row := range rows {
|
||||
totals[row.SourceName] = domain.VariantFileTotals{Files: row.Files, Bytes: row.Bytes}
|
||||
}
|
||||
return totals, nil
|
||||
}
|
||||
|
||||
func (v *VariantFileRepository) Totals() (map[string]domain.VariantFileTotals, error) {
|
||||
var rows []struct {
|
||||
VariantName string
|
||||
|
||||
Reference in new issue
Block a user