feat: add browse-at-scale — date ranges, load more, month navigator
CLI: --month YYYY-MM, --from/--to date range, --limit override API: from/to query params for date range filtering Web: load more button for pagination, month nav (◂/▸) in stream view
This commit is contained in:
@@ -47,6 +47,20 @@ func listEntities(store *db.Store) http.HandlerFunc {
|
||||
}
|
||||
p.Date = &date
|
||||
}
|
||||
if from := r.URL.Query().Get("from"); from != "" {
|
||||
if _, err := time.Parse("2006-01-02", from); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "invalid_input", "bad from format, use YYYY-MM-DD")
|
||||
return
|
||||
}
|
||||
p.From = &from
|
||||
}
|
||||
if to := r.URL.Query().Get("to"); to != "" {
|
||||
if _, err := time.Parse("2006-01-02", to); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "invalid_input", "bad to format, use YYYY-MM-DD")
|
||||
return
|
||||
}
|
||||
p.To = &to
|
||||
}
|
||||
if r.URL.Query().Get("cards_only") == "true" {
|
||||
p.CardsOnly = true
|
||||
}
|
||||
|
||||
@@ -64,6 +64,8 @@ type Entity struct {
|
||||
type ListParams struct {
|
||||
Tag *string
|
||||
Date *string
|
||||
From *string
|
||||
To *string
|
||||
Since *time.Time
|
||||
CardsOnly bool
|
||||
IncludeDeleted bool
|
||||
@@ -192,6 +194,14 @@ func (s *Store) List(params ListParams) ([]*Entity, error) {
|
||||
where = append(where, "date(e.created_at) = ?")
|
||||
args = append(args, *params.Date)
|
||||
}
|
||||
if params.From != nil {
|
||||
where = append(where, "date(e.created_at) >= ?")
|
||||
args = append(args, *params.From)
|
||||
}
|
||||
if params.To != nil {
|
||||
where = append(where, "date(e.created_at) <= ?")
|
||||
args = append(args, *params.To)
|
||||
}
|
||||
if params.Since != nil {
|
||||
where = append(where, "e.created_at >= ?")
|
||||
args = append(args, params.Since.Format(time.RFC3339))
|
||||
|
||||
Reference in New Issue
Block a user