fix: filter daily reports by date
This commit is contained in:
+10
-1
@@ -674,7 +674,16 @@ func (a *API) meetingNoteFileResource(w http.ResponseWriter, r *http.Request, p
|
||||
func (a *API) dailyReports(w http.ResponseWriter, r *http.Request, p *auth.Principal, st *store.Store) {
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
items, next, err := st.DailyReports(r.Context(), p.UserID, r.URL.Query().Get("cursor"), limit(r, 50, 100))
|
||||
reportDate := ""
|
||||
if rawDate := strings.TrimSpace(r.URL.Query().Get("date")); rawDate != "" {
|
||||
date, parseErr := parseDate(rawDate)
|
||||
if parseErr != nil {
|
||||
writeError(w, r, http.StatusBadRequest, 30000, reasonMalformedRequest, "malformed request", map[string]any{"field": "date"})
|
||||
return
|
||||
}
|
||||
reportDate = date.Format("2006-01-02")
|
||||
}
|
||||
items, next, err := st.DailyReports(r.Context(), p.UserID, reportDate, r.URL.Query().Get("cursor"), limit(r, 50, 100))
|
||||
if err != nil {
|
||||
writeStoreError(w, r, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user