mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
feat(releases): delete older than x (#924)
* feat: delete releases older than x * check timestamp * incomplete front end changes commiting changes from codespace to not lose them * change to dropdown with options * using int comparisons to avoid nightmares * Revert "using int comparisons to avoid nightmares" This reverts commit dc55966a73e9f6ad79ed28c3a3e0dbe0e35448a6. * suggestions by stacksmash76 come back to discord @stacksmash76 * Curves - a touch of warmth in our pixel realm * replace inline css with tailwind * remove unnecessary comment * align label with dropdown changed first paragraph to something more sensible * change font weight for duration label * padding changes * nitpicky * merged divs where possible * small adjustments for light theme * attempt to fix for postgres * refactor: split into component and add confirmation modal also restyle component * fix: go fmt --------- Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
parent
1f76aa38f4
commit
f774831d76
6 changed files with 182 additions and 54 deletions
|
@ -20,6 +20,7 @@ type releaseService interface {
|
|||
GetIndexerOptions(ctx context.Context) ([]string, error)
|
||||
Stats(ctx context.Context) (*domain.ReleaseStats, error)
|
||||
Delete(ctx context.Context) error
|
||||
DeleteOlder(ctx context.Context, duration int) error
|
||||
Retry(ctx context.Context, req *domain.ReleaseActionRetryReq) error
|
||||
}
|
||||
|
||||
|
@ -41,6 +42,7 @@ func (h releaseHandler) Routes(r chi.Router) {
|
|||
r.Get("/stats", h.getStats)
|
||||
r.Get("/indexers", h.getIndexerOptions)
|
||||
r.Delete("/all", h.deleteReleases)
|
||||
r.Delete("/older-than/{duration}", h.deleteOlder)
|
||||
|
||||
r.Route("/{releaseId}", func(r chi.Router) {
|
||||
r.Post("/actions/{actionStatusId}/retry", h.retryAction)
|
||||
|
@ -193,6 +195,28 @@ func (h releaseHandler) deleteReleases(w http.ResponseWriter, r *http.Request) {
|
|||
h.encoder.NoContent(w)
|
||||
}
|
||||
|
||||
func (h releaseHandler) deleteOlder(w http.ResponseWriter, r *http.Request) {
|
||||
durationStr := chi.URLParam(r, "duration")
|
||||
duration, err := strconv.Atoi(durationStr)
|
||||
if err != nil {
|
||||
h.encoder.StatusResponse(w, http.StatusBadRequest, map[string]interface{}{
|
||||
"code": "BAD_REQUEST_PARAMS",
|
||||
"message": "Invalid duration",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.service.DeleteOlder(r.Context(), duration); err != nil {
|
||||
h.encoder.StatusResponse(w, http.StatusInternalServerError, map[string]interface{}{
|
||||
"code": "INTERNAL_SERVER_ERROR",
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
h.encoder.NoContent(w)
|
||||
}
|
||||
|
||||
func (h releaseHandler) retryAction(w http.ResponseWriter, r *http.Request) {
|
||||
var (
|
||||
req *domain.ReleaseActionRetryReq
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue