plexus.dashboard.api.models.aggregated_metrics module
AggregatedMetrics Model - Python representation of the GraphQL AggregatedMetrics type.
This model represents pre-computed aggregation counts for Items, ScoreResults, Tasks, and Evaluations across different time buckets (1, 5, 15, 60 minutes).
Key Features: - Query aggregated metrics by time range - Create or update aggregation records (upsert logic) - Support for multiple record types (items, scoreResults, tasks, evaluations) - Hierarchical time bucketing for efficient queries
- class plexus.dashboard.api.models.aggregated_metrics.AggregatedMetrics(id: str, accountId: str, compositeKey: str, recordType: str, timeRangeStart: datetime, timeRangeEnd: datetime, numberOfMinutes: int, count: int, complete: bool, createdAt: datetime, updatedAt: datetime, client: _BaseAPIClient | None = None, scorecardId: str | None = None, scoreId: str | None = None, cost: int | None = None, decisionCount: int | None = None, externalAiApiCount: int | None = None, cachedAiApiCount: int | None = None, errorCount: int | None = None, metadata: Dict | None = None)
Bases:
BaseModelAggregatedMetrics model for interacting with the API.
- __init__(id: str, accountId: str, compositeKey: str, recordType: str, timeRangeStart: datetime, timeRangeEnd: datetime, numberOfMinutes: int, count: int, complete: bool, createdAt: datetime, updatedAt: datetime, client: _BaseAPIClient | None = None, scorecardId: str | None = None, scoreId: str | None = None, cost: int | None = None, decisionCount: int | None = None, externalAiApiCount: int | None = None, cachedAiApiCount: int | None = None, errorCount: int | None = None, metadata: Dict | None = None)
- accountId: str
- cachedAiApiCount: int | None = None
- complete: bool
- compositeKey: str
- cost: int | None = None
- count: int
- classmethod create_or_update(client: _BaseAPIClient, account_id: str, record_type: str, time_range_start: datetime, time_range_end: datetime, number_of_minutes: int, count: int, complete: bool = True, scorecard_id: str | None = None, score_id: str | None = None, cost: int | None = None, decision_count: int | None = None, external_ai_api_count: int | None = None, cached_ai_api_count: int | None = None, error_count: int | None = None, metadata: Dict | None = None) AggregatedMetrics
Create or update an aggregated metrics record (upsert logic).
This method first queries for an existing record matching the key fields (accountId, recordType, timeRangeStart, numberOfMinutes), then either updates it or creates a new one.
- Args:
client: The API client instance account_id: The account ID record_type: Type of record (items, scoreResults, tasks, evaluations) time_range_start: Start of the time range time_range_end: End of the time range number_of_minutes: Bucket size in minutes count: The aggregated count complete: Whether this bucket is complete scorecard_id: Optional scorecard ID score_id: Optional score ID cost: Optional cost value decision_count: Optional decision count external_ai_api_count: Optional external AI API count cached_ai_api_count: Optional cached AI API count error_count: Optional error count metadata: Optional metadata dictionary
- Returns:
The created or updated AggregatedMetrics instance
- createdAt: datetime
- decisionCount: int | None = None
- errorCount: int | None = None
- externalAiApiCount: int | None = None
- classmethod fields() str
Fields to request in queries and mutations
- classmethod from_dict(data: Dict[str, Any], client: _BaseAPIClient) AggregatedMetrics
Create an AggregatedMetrics instance from a dictionary.
- static generate_composite_key(record_type: str, time_range_start: datetime, number_of_minutes: int) str
Generate composite key for AggregatedMetrics.
- classmethod list_by_time_range(client: _BaseAPIClient, account_id: str, start_time: datetime, end_time: datetime, record_type: str | None = None) List[AggregatedMetrics]
Query aggregated metrics by time range using the GSI.
- Args:
client: The API client instance account_id: The account ID to filter by start_time: Start of the time range end_time: End of the time range record_type: Optional record type filter (items, scoreResults, tasks, evaluations)
- Returns:
List of AggregatedMetrics instances
- metadata: Dict | None = None
- numberOfMinutes: int
- recordType: str
- scoreId: str | None = None
- scorecardId: str | None = None
- timeRangeEnd: datetime
- timeRangeStart: datetime
- updatedAt: datetime