@@ -54,19 +54,16 @@ func GetArtifacts(c *fiber.Ctx) error {
5454 query .Limit = limit
5555 query .Offset = offset
5656
57- artifacts , err := artifactsService .GetArtifacts (query )
57+ result , err := artifactsService .GetArtifacts (query )
5858 if err != nil {
5959 return c .Status (fiber .StatusInternalServerError ).JSON (fiber.Map {
6060 "error" : err .Error (),
6161 "status" : fiber .StatusInternalServerError ,
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- }
65+ artifacts := result .Data
66+ totalFiltered := result .Total
7067
7168 // Get unique platforms and support statuses for metadata
7269 platformsMap := make (map [string ]bool )
@@ -88,10 +85,10 @@ func GetArtifacts(c *fiber.Ctx) error {
8885 return c .JSON (fiber.Map {
8986 "data" : artifacts ,
9087 "metadata" : fiber.Map {
91- "total" : total ,
88+ "total" : totalFiltered ,
9289 "limit" : limit ,
9390 "offset" : offset ,
94- "hasMore" : len (artifacts ) == limit ,
91+ "hasMore" : offset + len (artifacts ) < totalFiltered ,
9592 "platforms" : platforms ,
9693 "supportStatuses" : statuses ,
9794 "query" : fiber.Map {
@@ -133,23 +130,23 @@ func GetArtifactByVersion(c *fiber.Ctx) error {
133130 IncludeEOL : true ,
134131 }
135132
136- artifacts , err := artifactsService .GetArtifacts (query )
133+ result , err := artifactsService .GetArtifacts (query )
137134 if err != nil {
138135 return c .Status (fiber .StatusInternalServerError ).JSON (fiber.Map {
139136 "error" : err .Error (),
140137 })
141138 }
142139
143- if len (artifacts ) == 0 {
140+ if len (result . Data ) == 0 {
144141 return c .Status (fiber .StatusNotFound ).JSON (fiber.Map {
145142 "error" : "Artifact version not found" ,
146143 })
147144 }
148145
149146 return c .JSON (fiber.Map {
150147 "success" : true ,
151- "count" : len (artifacts ),
152- "data" : artifacts ,
148+ "count" : len (result . Data ),
149+ "data" : result . Data ,
153150 })
154151}
155152
@@ -176,14 +173,14 @@ func CheckArtifact(c *fiber.Ctx) error {
176173 IncludeEOL : true ,
177174 }
178175
179- artifacts , err := artifactsService .GetArtifacts (query )
176+ result , err := artifactsService .GetArtifacts (query )
180177 if err != nil {
181178 return c .Status (fiber .StatusInternalServerError ).JSON (fiber.Map {
182179 "error" : err .Error (),
183180 })
184181 }
185182
186- if len (artifacts ) == 0 {
183+ if len (result . Data ) == 0 {
187184 return c .Status (fiber .StatusNotFound ).JSON (fiber.Map {
188185 "error" : "Artifact version not found" ,
189186 "version" : version ,
@@ -194,8 +191,8 @@ func CheckArtifact(c *fiber.Ctx) error {
194191 "success" : true ,
195192 "version" : version ,
196193 "available" : true ,
197- "platformCount" : len (artifacts ),
198- "platforms" : artifacts ,
194+ "platformCount" : len (result . Data ),
195+ "platforms" : result . Data ,
199196 })
200197}
201198
@@ -223,15 +220,15 @@ func GetArtifactChanges(c *fiber.Ctx) error {
223220 baseQuery := services.ArtifactsQuery {Version : base , IncludeEOL : true }
224221 headQuery := services.ArtifactsQuery {Version : head , IncludeEOL : true }
225222
226- baseArtifacts , err := artifactsService .GetArtifacts (baseQuery )
227- if err != nil || len (baseArtifacts ) == 0 {
223+ baseResult , err := artifactsService .GetArtifacts (baseQuery )
224+ if err != nil || len (baseResult . Data ) == 0 {
228225 return c .Status (fiber .StatusNotFound ).JSON (fiber.Map {
229226 "error" : "Base version not found" ,
230227 })
231228 }
232229
233- headArtifacts , err := artifactsService .GetArtifacts (headQuery )
234- if err != nil || len (headArtifacts ) == 0 {
230+ headResult , err := artifactsService .GetArtifacts (headQuery )
231+ if err != nil || len (headResult . Data ) == 0 {
235232 return c .Status (fiber .StatusNotFound ).JSON (fiber.Map {
236233 "error" : "Head version not found" ,
237234 })
@@ -243,11 +240,11 @@ func GetArtifactChanges(c *fiber.Ctx) error {
243240 "base" : base ,
244241 "head" : head ,
245242 "comparison" : map [string ]interface {}{
246- "base_hash" : baseArtifacts [0 ].Hash ,
247- "head_hash" : headArtifacts [0 ].Hash ,
248- "base_date" : baseArtifacts [0 ].Date ,
249- "head_date" : headArtifacts [0 ].Date ,
250- "platforms" : len (headArtifacts ),
243+ "base_hash" : baseResult . Data [0 ].Hash ,
244+ "head_hash" : headResult . Data [0 ].Hash ,
245+ "base_date" : baseResult . Data [0 ].Date ,
246+ "head_date" : headResult . Data [0 ].Date ,
247+ "platforms" : len (headResult . Data ),
251248 },
252249 "message" : "Use GitHub API to fetch detailed commit history" ,
253250 })
0 commit comments