add correct backfile
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
f862abe5a4
commit
28e082f0fc
8 changed files with 317 additions and 35 deletions
|
|
@ -42,6 +42,7 @@ func (h *SnapshotHandler) RegisterRoutes(mux *http.ServeMux) {
|
|||
mux.HandleFunc("GET /accounts/{id}/snapshots", h.listAccountSnapshots)
|
||||
mux.HandleFunc("GET /accounts/{id}/snapshots/positions", h.listPositionSnapshots)
|
||||
mux.HandleFunc("POST /accounts/{id}/snapshots/recompute", h.recomputeAccount)
|
||||
mux.HandleFunc("GET /snapshots/pending", h.listPending)
|
||||
}
|
||||
|
||||
// parseDateParam parse un paramètre de query YYYY-MM-DD. Retourne time.Time{} si absent.
|
||||
|
|
@ -53,6 +54,33 @@ func parseDateParam(r *http.Request, key string) (time.Time, error) {
|
|||
return time.Parse("2006-01-02", v)
|
||||
}
|
||||
|
||||
// GET /snapshots/pending
|
||||
// Liste les comptes de l'owner ayant une invalidation en attente.
|
||||
func (h *SnapshotHandler) listPending(w http.ResponseWriter, r *http.Request) {
|
||||
ownerID, ok := requireOwner(w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
invalidations, err := h.engine.Store().GetInvalidationsForOwner(r.Context(), ownerID)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
type row struct {
|
||||
AccountID int32 `json:"account_id"`
|
||||
RecomputeFrom string `json:"recompute_from"`
|
||||
}
|
||||
out := make([]row, 0, len(invalidations))
|
||||
for _, inv := range invalidations {
|
||||
out = append(out, row{
|
||||
AccountID: inv.AccountID,
|
||||
RecomputeFrom: inv.RecomputeFrom.Format("2006-01-02"),
|
||||
})
|
||||
}
|
||||
writeJSON(w, http.StatusOK, out)
|
||||
}
|
||||
|
||||
// GET /accounts/{id}/snapshots?from=YYYY-MM-DD&to=YYYY-MM-DD
|
||||
// Liste les snapshots agrégés (valeur totale) d'un compte.
|
||||
// from/to optionnels : sans borne → pas de filtre de ce côté.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue