Skip to content

Commit d020c78

Browse files
committed
fix: artifacts stuff
1 parent 3fdbc43 commit d020c78

1 file changed

Lines changed: 42 additions & 5 deletions

File tree

internal/handlers/artifacts.go

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,49 @@ func GetArtifacts(c *fiber.Ctx) error {
6262
})
6363
}
6464

65+
// Calculate total (assuming all artifacts match without offset)
66+
total := len(artifacts) + offset
67+
if len(artifacts) < limit {
68+
total = offset + len(artifacts)
69+
}
70+
71+
// Get unique platforms and support statuses for metadata
72+
platformsMap := make(map[string]bool)
73+
statusesMap := make(map[string]bool)
74+
for _, artifact := range artifacts {
75+
platformsMap[string(artifact.Platform)] = true
76+
statusesMap[string(artifact.SupportStatus)] = true
77+
}
78+
79+
platforms := make([]string, 0)
80+
statuses := make([]string, 0)
81+
for p := range platformsMap {
82+
platforms = append(platforms, p)
83+
}
84+
for s := range statusesMap {
85+
statuses = append(statuses, s)
86+
}
87+
6588
return c.JSON(fiber.Map{
66-
"success": true,
67-
"count": len(artifacts),
68-
"data": artifacts,
69-
"limit": limit,
70-
"offset": offset,
89+
"data": artifacts,
90+
"metadata": fiber.Map{
91+
"total": total,
92+
"limit": limit,
93+
"offset": offset,
94+
"hasMore": len(artifacts) == limit,
95+
"platforms": platforms,
96+
"supportStatuses": statuses,
97+
"query": fiber.Map{
98+
"platform": query.Platform,
99+
"version": query.Version,
100+
"status": string(query.Status),
101+
"limit": limit,
102+
"offset": offset,
103+
"sortBy": query.SortBy,
104+
"sortOrder": query.SortOrder,
105+
"includeEol": query.IncludeEOL,
106+
},
107+
},
71108
})
72109
}
73110

0 commit comments

Comments
 (0)