2022-07-16 22:20:56 +01:00
|
|
|
package index
|
|
|
|
|
2022-07-28 01:56:00 +01:00
|
|
|
import (
|
|
|
|
"html/template"
|
|
|
|
"sort"
|
|
|
|
)
|
2022-07-16 22:20:56 +01:00
|
|
|
|
|
|
|
type Marshal struct {
|
|
|
|
Data DataYaml
|
2022-07-28 01:56:00 +01:00
|
|
|
Parameters template.URL
|
2022-07-16 22:20:56 +01:00
|
|
|
OrderStartDate int8
|
|
|
|
OrderEndDate int8
|
|
|
|
OrderName int8
|
|
|
|
OrderDuration int8
|
2022-07-17 13:37:50 +01:00
|
|
|
Light bool
|
2022-07-30 15:07:10 +01:00
|
|
|
Counter int
|
2022-07-16 22:20:56 +01:00
|
|
|
}
|
|
|
|
|
2022-07-30 15:07:10 +01:00
|
|
|
func (m *Marshal) GetEntries() (toReturn []EntryYaml) {
|
2022-07-16 22:20:56 +01:00
|
|
|
toReturn = m.Data.Entries
|
|
|
|
if m.OrderStartDate > 0 {
|
|
|
|
sort.Slice(toReturn, func(i, j int) bool {
|
2022-07-28 01:56:00 +01:00
|
|
|
return toReturn[i].StartDate.Before(toReturn[j].StartDate.Time)
|
2022-07-16 22:20:56 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
if m.OrderStartDate < 0 {
|
|
|
|
sort.Slice(toReturn, func(i, j int) bool {
|
2022-07-28 01:56:00 +01:00
|
|
|
return toReturn[i].StartDate.After(toReturn[j].StartDate.Time)
|
2022-07-16 22:20:56 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
if m.OrderEndDate > 0 {
|
|
|
|
sort.Slice(toReturn, func(i, j int) bool {
|
|
|
|
return toReturn[i].GetEndTime().Before(toReturn[j].GetEndTime())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if m.OrderEndDate < 0 {
|
|
|
|
sort.Slice(toReturn, func(i, j int) bool {
|
|
|
|
return toReturn[i].GetEndTime().After(toReturn[j].GetEndTime())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if m.OrderName > 0 {
|
|
|
|
sort.Slice(toReturn, func(i, j int) bool {
|
|
|
|
return toReturn[i].Name < toReturn[j].Name
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if m.OrderName < 0 {
|
|
|
|
sort.Slice(toReturn, func(i, j int) bool {
|
|
|
|
return toReturn[i].Name > toReturn[j].Name
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if m.OrderDuration > 0 {
|
|
|
|
sort.Slice(toReturn, func(i, j int) bool {
|
|
|
|
return toReturn[i].GetDuration() < toReturn[j].GetDuration()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if m.OrderDuration < 0 {
|
|
|
|
sort.Slice(toReturn, func(i, j int) bool {
|
|
|
|
return toReturn[i].GetDuration() > toReturn[j].GetDuration()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return toReturn
|
|
|
|
}
|
2022-07-30 15:07:10 +01:00
|
|
|
|
|
|
|
func (m *Marshal) CounterPlusPlus() int {
|
|
|
|
toret := m.Counter
|
|
|
|
m.Counter++
|
|
|
|
return toret
|
|
|
|
}
|