(ctx context.Context, clusterId string, apiInfos []*api.Info, start time.Time, end time.Time, wheres []monitor.MonWhereItem, limit int)
| 529 | } |
| 530 | |
| 531 | func (i *imlMonitorStatisticModule) apiStatistics(ctx context.Context, clusterId string, apiInfos []*api.Info, start time.Time, end time.Time, wheres []monitor.MonWhereItem, limit int) ([]*monitor_dto.ApiStatisticBasicItem, error) { |
| 532 | statisticMap, err := i.statistics(ctx, clusterId, "api", start, end, wheres, limit) |
| 533 | if err != nil { |
| 534 | return nil, err |
| 535 | } |
| 536 | |
| 537 | result := make([]*monitor_dto.ApiStatisticBasicItem, 0, len(statisticMap)) |
| 538 | for _, item := range apiInfos { |
| 539 | |
| 540 | statisticItem := &monitor_dto.ApiStatisticBasicItem{ |
| 541 | Id: item.UUID, |
| 542 | Name: item.Name, |
| 543 | Path: item.Path, |
| 544 | Service: auto.UUID(item.Service), |
| 545 | MonCommonData: new(monitor_dto.MonCommonData), |
| 546 | } |
| 547 | if val, ok := statisticMap[item.UUID]; ok { |
| 548 | statisticItem.MonCommonData = monitor_dto.ToMonCommonData(val) |
| 549 | delete(statisticMap, item.UUID) |
| 550 | } |
| 551 | result = append(result, statisticItem) |
| 552 | } |
| 553 | for key, item := range statisticMap { |
| 554 | statisticItem := &monitor_dto.ApiStatisticBasicItem{ |
| 555 | Id: key, |
| 556 | Name: "未知API-" + key, |
| 557 | MonCommonData: monitor_dto.ToMonCommonData(item), |
| 558 | } |
| 559 | |
| 560 | if key == "-" { |
| 561 | statisticItem.Name = "无API" |
| 562 | } |
| 563 | result = append(result, statisticItem) |
| 564 | } |
| 565 | sort.Slice(result, func(i, j int) bool { |
| 566 | return result[i].RequestTotal > result[j].RequestTotal |
| 567 | }) |
| 568 | return result, nil |
| 569 | } |
| 570 | |
| 571 | func (i *imlMonitorStatisticModule) SubscriberStatistics(ctx context.Context, input *monitor_dto.StatisticInput) ([]*monitor_dto.ServiceStatisticBasicItem, error) { |
| 572 | clusterId := cluster.DefaultClusterID |
no test coverage detected