2020-11-01 14:50:59 +03:00
|
|
|
package models
|
|
|
|
|
|
|
|
type Filters struct {
|
|
|
|
Project string
|
|
|
|
OS string
|
|
|
|
Language string
|
|
|
|
Editor string
|
|
|
|
Machine string
|
2021-06-11 21:59:34 +03:00
|
|
|
Label string
|
2020-11-01 14:50:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type FilterElement struct {
|
|
|
|
Type uint8
|
|
|
|
Key string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewFiltersWith(entity uint8, key string) *Filters {
|
|
|
|
switch entity {
|
|
|
|
case SummaryProject:
|
|
|
|
return &Filters{Project: key}
|
|
|
|
case SummaryOS:
|
2020-11-07 20:39:36 +03:00
|
|
|
return &Filters{OS: key}
|
2020-11-01 14:50:59 +03:00
|
|
|
case SummaryLanguage:
|
2020-11-07 20:39:36 +03:00
|
|
|
return &Filters{Language: key}
|
2020-11-01 14:50:59 +03:00
|
|
|
case SummaryEditor:
|
2020-11-07 20:39:36 +03:00
|
|
|
return &Filters{Editor: key}
|
2020-11-01 14:50:59 +03:00
|
|
|
case SummaryMachine:
|
2020-11-07 20:39:36 +03:00
|
|
|
return &Filters{Machine: key}
|
2021-06-11 21:59:34 +03:00
|
|
|
case SummaryLabel:
|
|
|
|
return &Filters{Label: key}
|
2020-11-01 14:50:59 +03:00
|
|
|
}
|
|
|
|
return &Filters{}
|
|
|
|
}
|
|
|
|
|
2021-01-31 18:23:47 +03:00
|
|
|
func (f *Filters) One() (bool, uint8, string) {
|
2020-11-01 14:50:59 +03:00
|
|
|
if f.Project != "" {
|
|
|
|
return true, SummaryProject, f.Project
|
|
|
|
} else if f.OS != "" {
|
|
|
|
return true, SummaryOS, f.OS
|
|
|
|
} else if f.Language != "" {
|
|
|
|
return true, SummaryLanguage, f.Language
|
|
|
|
} else if f.Editor != "" {
|
|
|
|
return true, SummaryEditor, f.Editor
|
|
|
|
} else if f.Machine != "" {
|
|
|
|
return true, SummaryMachine, f.Machine
|
2021-06-13 11:14:15 +03:00
|
|
|
} else if f.Label != "" {
|
2021-06-11 21:59:34 +03:00
|
|
|
return true, SummaryLabel, f.Label
|
2020-11-01 14:50:59 +03:00
|
|
|
}
|
|
|
|
return false, 0, ""
|
|
|
|
}
|