Skip to main content

Duration Statistics Types

Types for tracking and analyzing duration-based metrics for trackers.

DurationStats

Represents statistical information about tracker durations.

type DurationStats {
"""
Average time trackers spend in transit (in hours).
"""
averageTransitTime: Int!

"""
Average time trackers spend in storage (in hours).
"""
averageStorageTime: Int!

"""
Total number of trackers included in the statistics.
"""
totalTrackers: Int!
}

Example Usage

Basic Duration Stats Query

query GetDurationStats {
durationStats {
averageTransitTime
averageStorageTime
totalTrackers
}
}

Filtered Duration Stats Query

query GetFilteredDurationStats {
durationStats(
filters: {
brandId: "123"
currentStatuses: [IN_TRANSIT, STORED]
productionRunIds: ["456", "789"]
}
) {
averageTransitTime
averageStorageTime
totalTrackers
}
}

Duration Tracking Fields

The following fields are available on the Tracker type for individual duration tracking:

type Tracker {
# ... other fields ...

"""
Total time this tracker has spent in transit (in hours).
"""
totalTransitTime: Int!

"""
Total time this tracker has spent in storage (in hours).
"""
totalStorageTime: Int!

"""
Timestamp when the current state began.
"""
currentStateStart: DateTime
}

Best Practices

  1. Time Calculations

    • All durations are provided in hours
    • Use appropriate time zone handling
    • Consider caching duration calculations
  2. Filtering

    • Use filters to analyze specific subsets of trackers
    • Consider the impact of status changes on durations
    • Account for incomplete or ongoing durations
  3. Performance

    • Duration calculations are computationally intensive
    • Use appropriate indexes for status and timestamp fields
    • Consider implementing caching strategies
  4. Analysis

    • Compare durations across different time periods
    • Monitor trends in transit vs storage time
    • Use filters to identify optimization opportunities