MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / SumByApisPage

Method SumByApisPage

service/ai-api/iml.go:162–178  ·  view source on GitHub ↗
(ctx context.Context, providerId string, start, end int64, offset, limit int, order string, apiIds ...string)

Source from the content-addressed store, hash-verified

160}
161
162func (i *imlAPIUseService) SumByApisPage(ctx context.Context, providerId string, start, end int64, offset, limit int, order string, apiIds ...string) ([]*APIUse, int64, error) {
163 list, total, err := i.store.SumByGroupPage(ctx, "api", order, offset, limit, "api,sum(input_token) as input_token,sum(output_token) as output_token,sum(total_token) as total_token", "provider = ? and api in (?) and minute >= ? and minute <= ?", providerId, apiIds, start, end)
164 if err != nil {
165 return nil, 0, err
166 }
167
168 result := make([]*APIUse, 0, len(list))
169 for _, v := range list {
170 result = append(result, &APIUse{
171 API: v.API,
172 InputToken: v.InputToken,
173 OutputToken: v.OutputToken,
174 TotalToken: v.TotalToken,
175 })
176 }
177 return result, total, nil
178}
179
180func (i *imlAPIUseService) SumByApis(ctx context.Context, providerId string, start, end int64, apiIds ...string) ([]*APIUse, error) {
181 //list, err := i.store.SumByGroup(ctx, "api", "api,sum(input_token) as input_token,sum(output_token) as output_token,sum(total_token) as total_token", "provider = ? and api in (?) and minute >= ? and minute <= ?", providerId, apiIds, start, end)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected