MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / SubscriberStatistics

Method SubscriberStatistics

module/monitor/iml.go:571–604  ·  view source on GitHub ↗
(ctx context.Context, input *monitor_dto.StatisticInput)

Source from the content-addressed store, hash-verified

569}
570
571func (i *imlMonitorStatisticModule) SubscriberStatistics(ctx context.Context, input *monitor_dto.StatisticInput) ([]*monitor_dto.ServiceStatisticBasicItem, error) {
572 clusterId := cluster.DefaultClusterID
573 _, err := i.clusterService.Get(ctx, clusterId)
574 if err != nil {
575 return nil, err
576 }
577
578 apps, err := i.serviceService.AppList(ctx, input.Services...)
579 if err != nil {
580 return nil, err
581 }
582 apps = append(apps, &service.Service{
583 Id: "apipark-global",
584 Name: "System Consumer",
585 })
586 appIds := utils.SliceToSlice(apps, func(p *service.Service) string {
587 return p.Id
588 })
589
590 wheres, err := i.genCommonWheres(ctx, clusterId)
591 if err != nil {
592 return nil, err
593 }
594
595 if len(appIds) > 0 {
596 wheres = append(wheres, monitor.MonWhereItem{
597 Key: "app",
598 Operation: "in",
599 Values: appIds,
600 })
601 }
602
603 return i.serviceStatistics(ctx, clusterId, apps, "app", formatTimeByMinute(input.Start), formatTimeByMinute(input.End), wheres, 0)
604}
605
606func (i *imlMonitorStatisticModule) serviceStatistics(ctx context.Context, clusterId string, services []*service.Service, groupBy string, start time.Time, end time.Time, wheres []monitor.MonWhereItem, limit int) ([]*monitor_dto.ServiceStatisticBasicItem, error) {
607 statisticMap, err := i.statistics(ctx, clusterId, groupBy, start, end, wheres, limit)

Callers

nothing calls this directly

Calls 5

genCommonWheresMethod · 0.95
serviceStatisticsMethod · 0.95
formatTimeByMinuteFunction · 0.70
GetMethod · 0.65
AppListMethod · 0.65

Tested by

no test coverage detected