forked from mirrors/homebox
feat: new homepage statistic API's (#167)
* add date format and orDefault helpers * introduce new statistics calculations queries * rework statistics endpoints * code generation * fix styles on photo card * label and location aggregation endpoints * code-gen * cleanup parser and defaults * remove debug point * setup E2E Testing * linters * formatting * fmt plus name support on time series data * code gen
This commit is contained in:
parent
de419dc37d
commit
d6da63187b
19 changed files with 925 additions and 149 deletions
18
backend/internal/data/repo/query_helpers.go
Normal file
18
backend/internal/data/repo/query_helpers.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package repo
|
||||
|
||||
import "time"
|
||||
|
||||
func sqliteDateFormat(t time.Time) string {
|
||||
return t.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
// orDefault returns the value of the pointer if it is not nil, otherwise it returns the default value
|
||||
//
|
||||
// This is used for nullable or potentially nullable fields (or aggregates) in the database when running
|
||||
// queries. If the field is null, the pointer will be nil, so we return the default value instead.
|
||||
func orDefault[T any](v *T, def T) T {
|
||||
if v == nil {
|
||||
return def
|
||||
}
|
||||
return *v
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue