package validation

import "time"

type Create struct {
	Name string `json:"name" validate:"required_strict,min=3"`
}

const (
	AnalysisModeOverview   = "OVERVIEW"
	AnalysisModeComparison = "COMPARISON"

	ComparisonTypeFarm    = "FARM"
	ComparisonTypeFlock   = "FLOCK"
	ComparisonTypeKandang = "KANDANG"

	MetricFcr        = "fcr"
	MetricMortality  = "mortality"
	MetricLaying     = "laying"
	MetricEggWeight  = "egg_weight"
	MetricFeedIntake = "feed_intake"
)

type Update struct {
	Name *string `json:"name,omitempty" validate:"omitempty"`
}

type Query struct {
	Page   int    `query:"page" validate:"omitempty,number,min=1,gt=0"`
	Limit  int    `query:"limit" validate:"omitempty,number,min=1,max=100,gt=0"`
	Search string `query:"search" validate:"omitempty,max=50"`
	PerformanceOverviewFilter
	PeriodStart        time.Time `json:"-" query:"-"`
	PeriodEnd          time.Time `json:"-" query:"-"`
	PeriodEndExclusive time.Time `json:"-" query:"-"`
}

type PerformanceOverviewFilter struct {
	StartDate      string   `query:"start_date" validate:"omitempty,datetime=2006-01-02"`
	EndDate        string   `query:"end_date" validate:"omitempty,datetime=2006-01-02"`
	AnalysisMode   string   `query:"analysis_mode" validate:"omitempty,oneof=OVERVIEW COMPARISON"`
	ComparisonType string   `query:"comparison_type" validate:"omitempty,oneof=FARM FLOCK KANDANG"`
	Metric         string   `query:"metric" validate:"omitempty,oneof=fcr mortality laying egg_weight feed_intake"`
	LokasiIds      []uint   `query:"location_ids" validate:"omitempty,dive,gt=0"`
	FlockIds       []uint   `query:"flock_ids" validate:"omitempty,dive,gt=0"`
	KandangIds     []uint   `query:"kandang_ids" validate:"omitempty,dive,gt=0"`
	Include        []string `query:"include" validate:"omitempty,dive,oneof=statistics charts"`
}

type DashboardFilter struct {
	LokasiIds  []uint
	FlockIds   []uint
	KandangIds []uint
}
