feat: add updated_at to modpacks and /api/launcher/modpacks/summary endpoint

This commit is contained in:
Mrixs committed 2026-01-04 14:38:21 +03:00
1 parent e98d10ae1d
commit 275c1f2d50
4 files changed
+45

No files matched your search

+25
View File
@@ -101,3 +101,28 @@ func (r *ModpackRepository) GetAllFileHashes(ctx context.Context) (map[string]st
return hashes, rows.Err()
}
// GetModpacksSummary возвращает список всех активных модпаков с датой последнего обновления.
func (r *ModpackRepository) GetModpacksSummary(ctx context.Context) ([]models.ModpackSummary, error) {
query := `
SELECT name, updated_at
FROM modpacks
WHERE is_active = TRUE`
rows, err := r.DB.Query(ctx, query)
if err != nil {
return nil, err
}
defer rows.Close()
var summaries []models.ModpackSummary
for rows.Next() {
var s models.ModpackSummary
if err := rows.Scan(&s.Name, &s.UpdatedAt); err != nil {
return nil, err
}
summaries = append(summaries, s)
}
return summaries, nil
}