package workspace

type OverviewPeriod struct {
	From int64 `json:"from"`
	To   int64 `json:"to"` // Exclusive.
}

type OverviewMeta struct {
	QueriedAt      int64          `json:"queried_at"`
	AgeReferenceAt int64          `json:"age_reference_at"`
	Timezone       string         `json:"timezone"`
	Period         OverviewPeriod `json:"period"`
	PreviousPeriod OverviewPeriod `json:"previous_period"`
	HasCases       *bool          `json:"has_cases"` // Null when the existence query is unavailable.
}

type OverviewSectionMeta struct {
	Status    string `json:"status" enums:"available,unavailable"`
	QueriedAt int64  `json:"queried_at"`
	Error     string `json:"error,omitempty"` // Public error code, never a database error.
}

type OverviewSummary struct {
	NewCases         int64 `json:"new_cases"`
	ResolvedCases    int64 `json:"resolved_cases"`
	OpenNow          int64 `json:"open_now"`
	HighSeverityOpen int64 `json:"high_severity_open"`
	P1Open           int64 `json:"p1_open"`
	P2Open           int64 `json:"p2_open"`
}

type OverviewComparison struct {
	NewCases      int64 `json:"new_cases"`
	ResolvedCases int64 `json:"resolved_cases"`
}

type OverviewVolumeDay struct {
	Date string `json:"date"`
	OverviewPeriod
	NewCases      int64 `json:"new_cases"`
	ResolvedCases int64 `json:"resolved_cases"`
	Partial       bool  `json:"partial"`
}

type OverviewAgeBucket struct {
	Bucket string `json:"bucket"`
	Count  int64  `json:"count"`
}

type OverviewOwnerCount struct {
	Owner string `json:"owner"`
	Count int64  `json:"count"`
}

type OverviewOwners struct {
	Owners         []OverviewOwnerCount `json:"owners"`
	TopOwnerEmails []string             `json:"top_owner_emails"`
	Others         int64                `json:"others"`
	Unassigned     int64                `json:"unassigned"`
}

type OverviewReviewCounts struct {
	HighSeverity    int64 `json:"high_severity"`
	Aging           int64 `json:"aging"`
	Unassigned      int64 `json:"unassigned"`
	AllOpen         int64 `json:"all_open"`
	RecentlyStarted int64 `json:"recently_started"`
}

type OverviewDataQuality struct {
	MissingStartedAt   int64 `json:"missing_started_at"`
	MissingRecoveredAt int64 `json:"missing_recovered_at"`
}

type OverviewSummarySection struct {
	OverviewSectionMeta
	Data *OverviewSummary `json:"data,omitempty"`
}

type OverviewComparisonSection struct {
	OverviewSectionMeta
	Data *OverviewComparison `json:"data,omitempty"`
}

type OverviewVolumeSection struct {
	OverviewSectionMeta
	Data *[]OverviewVolumeDay `json:"data,omitempty"`
}

type OverviewAgeSection struct {
	OverviewSectionMeta
	Data *[]OverviewAgeBucket `json:"data,omitempty"`
}

type OverviewOwnersSection struct {
	OverviewSectionMeta
	Data *OverviewOwners `json:"data,omitempty"`
}

type OverviewReviewSection struct {
	OverviewSectionMeta
	Data *OverviewReviewCounts `json:"data,omitempty"`
}

type OverviewQualitySection struct {
	OverviewSectionMeta
	Data *OverviewDataQuality `json:"data,omitempty"`
}

type Overview struct {
	Meta         OverviewMeta               `json:"meta"`
	Summary      *OverviewSummarySection    `json:"summary,omitempty"`
	Comparison   *OverviewComparisonSection `json:"comparison,omitempty"`
	Volume       *OverviewVolumeSection     `json:"volume,omitempty"`
	OpenAge      *OverviewAgeSection        `json:"open_age,omitempty"`
	OpenByOwner  *OverviewOwnersSection     `json:"open_by_owner,omitempty"`
	ReviewCounts *OverviewReviewSection     `json:"review_counts,omitempty"`
	DataQuality  *OverviewQualitySection    `json:"data_quality,omitempty"`
}
