diff --git a/services/backend/src/routes/errors.rs b/services/backend/src/routes/errors.rs
index 620008a..994bf7b 100644
--- a/services/backend/src/routes/errors.rs
+++ b/services/backend/src/routes/errors.rs
@@ -1,8 +1,10 @@
//! Admin: the error log of the analyses, answers and prompt test runs (every
-//! failed attempt, written by the worker), newest first.
+//! failed attempt, written by the worker), newest first. Entries can be
+//! deleted one by one or all that match a filter.
use axum::Json;
-use axum::extract::{Query, State};
+use axum::extract::{Path, Query, State};
+use axum::http::StatusCode;
use axum_extra::extract::WithRejection;
use serde::Deserialize;
use serde_json::{Value, json};
@@ -71,3 +73,41 @@ pub async fn list(
.collect();
Ok(Json(json!({ "errors": errors, "total": total, "last_day": last_day, "limit": limit, "offset": offset })))
}
+
+#[derive(Deserialize)]
+#[serde(deny_unknown_fields)]
+pub struct DeleteQuery {
+ source: Option,
+ outcome: Option,
+}
+
+/// Deletes every entry matching the filter (none given: all of them).
+pub async fn delete_matching(
+ State(state): St,
+ AdminUser(admin): AdminUser,
+ WithRejection(Query(query), _): WithRejection, ApiError>,
+) -> ApiResult> {
+ let deleted = sqlx::query(
+ "DELETE FROM generation_errors WHERE ($1::text IS NULL OR source = $1) AND ($2::text IS NULL OR outcome = $2)",
+ )
+ .bind(&query.source)
+ .bind(&query.outcome)
+ .execute(&state.db)
+ .await?
+ .rows_affected();
+ tracing::info!(admin = %admin.id(), deleted, "error log entries deleted");
+ Ok(Json(json!({ "deleted": deleted })))
+}
+
+/// Deletes one entry.
+pub async fn delete_one(
+ State(state): St,
+ _admin: AdminUser,
+ WithRejection(Path(id), _): WithRejection, ApiError>,
+) -> ApiResult {
+ let result = sqlx::query("DELETE FROM generation_errors WHERE id = $1").bind(id).execute(&state.db).await?;
+ if result.rows_affected() == 0 {
+ return Err(ApiError::NotFound("error"));
+ }
+ Ok(StatusCode::NO_CONTENT)
+}
diff --git a/services/backend/src/routes/mod.rs b/services/backend/src/routes/mod.rs
index 8ee82fb..73380e1 100644
--- a/services/backend/src/routes/mod.rs
+++ b/services/backend/src/routes/mod.rs
@@ -147,7 +147,8 @@ pub fn router(state: Arc) -> Router {
.route("/v1/admin/prompts/{kind}/{language}", axum::routing::put(prompts::save))
.route("/v1/admin/prompts/{kind}/{language}/preview", post(prompts::start_preview))
.route("/v1/admin/previews/{id}", get(prompts::get_preview))
- .route("/v1/admin/errors", get(errors::list))
+ .route("/v1/admin/errors", get(errors::list).delete(errors::delete_matching))
+ .route("/v1/admin/errors/{id}", axum::routing::delete(errors::delete_one))
.route("/v1/admin/jobs", get(jobs::list))
.route("/v1/admin/jobs/restart", post(jobs::restart))
.route("/v1/admin/models", get(models::list))
diff --git a/services/backend/src/tests.rs b/services/backend/src/tests.rs
index 375ba4a..ff99f03 100644
--- a/services/backend/src/tests.rs
+++ b/services/backend/src/tests.rs
@@ -2214,6 +2214,19 @@ async fn admins_read_the_error_log(pool: PgPool) {
let r = app.get("/v1/admin/errors?outcome=retry", Some(&admin)).await;
assert_eq!(r.body["errors"].as_array().unwrap().len(), 1);
assert_eq!(app.get("/v1/admin/errors?source=question", Some(&admin)).await.body["total"], 0);
+ // deleted one by one, or all that match the filter
+ let retry_id = r.body["errors"][0]["id"].as_i64().unwrap();
+ let r = app.call("DELETE", &format!("/v1/admin/errors/{retry_id}"), Some(&anna), None).await;
+ assert_eq!(r.status, StatusCode::FORBIDDEN);
+ let r = app.call("DELETE", &format!("/v1/admin/errors/{retry_id}"), Some(&admin), None).await;
+ assert_eq!(r.status, StatusCode::NO_CONTENT);
+ let r = app.call("DELETE", &format!("/v1/admin/errors/{retry_id}"), Some(&admin), None).await;
+ assert_eq!(r.status, StatusCode::NOT_FOUND);
+ let r = app.call("DELETE", "/v1/admin/errors?outcome=retry", Some(&admin), None).await;
+ assert_eq!(r.body["deleted"], 0);
+ let r = app.call("DELETE", "/v1/admin/errors?source=analysis", Some(&admin), None).await;
+ assert_eq!((r.status, &r.body["deleted"]), (StatusCode::OK, &json!(1)), "{}", r.body);
+ assert_eq!(app.get("/v1/admin/errors", Some(&admin)).await.body["total"], 0);
// users see the attempts of their analysis (the page says it is tried again)
let r = app.get(&format!("/v1/analyses/{analysis}"), Some(&anna)).await;
assert_eq!(r.body["attempts"], 0);
diff --git a/services/frontend/src/app/Landing.tsx b/services/frontend/src/app/Landing.tsx
index c99e06a..26a6bbe 100644
--- a/services/frontend/src/app/Landing.tsx
+++ b/services/frontend/src/app/Landing.tsx
@@ -4,7 +4,6 @@ import { ChartWheel } from "@/components/ChartWheel";
import { Rich } from "@/components/Rich";
import { TarotCard, TarotCardBack } from "@/components/tarot/TarotCard";
import { Logo, PublicHeader } from "@/components/SiteHeader";
-import { Waitlist } from "@/components/Waitlist";
import example from "@/content/pelda.json";
import { tarotCard } from "@/lib/tarot";
import type { AnalysisContent, ChartResult } from "@/lib/types";
@@ -84,8 +83,7 @@ export function Landing({ inviteOnly }: { inviteOnly: boolean }) {
{inviteOnly ? (
<>
- Az oldal egyelőre meghívásos: meghívóval, Google-fiókkal lépsz be. Ha még nincs meghívód,{" "}
- iratkozz fel a várólistára.
+ Az oldal egyelőre meghívásos: meghívóval, Google-fiókkal lépsz be.
>
) : (
"A képlet és a rövid összefoglaló ingyenes. Google-fiókkal lépsz be."
@@ -458,7 +456,7 @@ export function Landing({ inviteOnly }: { inviteOnly: boolean }) {
-
+
- )}
-
- );
-}
diff --git a/services/frontend/src/app/belepes/AppleLogin.tsx b/services/frontend/src/app/belepes/AppleLogin.tsx
index 8eef023..dd91edc 100644
--- a/services/frontend/src/app/belepes/AppleLogin.tsx
+++ b/services/frontend/src/app/belepes/AppleLogin.tsx
@@ -4,7 +4,6 @@ import Script from "next/script";
import { useRouter } from "next/navigation";
import { useState } from "react";
-import { Waitlist } from "@/components/Waitlist";
import { ApiError, api, errorText } from "@/lib/api";
/** The part of Sign in with Apple JS (appleid.auth.js) we use. */
@@ -136,7 +135,6 @@ export function AppleLogin({
? "Ez a meghívó már nem érvényes, és ehhez az Apple-fiókhoz sem tartozik másik."
: "A Sorsfonalak jelenleg meghívásos, és ehhez az Apple-fiókhoz nem tartozik meghívó. Ha kaptál meghívót, nyisd meg a levélben kapott linket, vagy lépj be azzal a fiókkal, amelynek a címére a meghívó szólt."}
-
>
)}
diff --git a/services/frontend/src/app/belepes/GoogleLogin.tsx b/services/frontend/src/app/belepes/GoogleLogin.tsx
index 4b3117d..982d1c6 100644
--- a/services/frontend/src/app/belepes/GoogleLogin.tsx
+++ b/services/frontend/src/app/belepes/GoogleLogin.tsx
@@ -4,7 +4,6 @@ import Script from "next/script";
import { useRouter } from "next/navigation";
import { useCallback, useEffect, useRef, useState } from "react";
-import { Waitlist } from "@/components/Waitlist";
import { ApiError, api, errorText } from "@/lib/api";
/** Google's "G" mark (branding guidelines: unmodified, on the left of the label). */
@@ -130,7 +129,6 @@ export function GoogleLogin({
? "Ez a meghívó már nem érvényes, és ehhez a Google-fiókhoz sem tartozik másik."
: `A Sorsfonalak jelenleg meghívásos, és ${uninvited ? `a(z) ${uninvited} címhez` : "ehhez a fiókhoz"} nem tartozik meghívó. Ha kaptál meghívót egy másik címre, lépj be azzal a Google-fiókkal, vagy nyisd meg a levélben kapott linket.`}
-
>
)}
diff --git a/services/frontend/src/app/belepes/PasswordLogin.tsx b/services/frontend/src/app/belepes/PasswordLogin.tsx
index 14e6cbf..ad53be0 100644
--- a/services/frontend/src/app/belepes/PasswordLogin.tsx
+++ b/services/frontend/src/app/belepes/PasswordLogin.tsx
@@ -3,7 +3,6 @@
import { useRouter } from "next/navigation";
import { useState } from "react";
-import { Waitlist } from "@/components/Waitlist";
import { ApiError, api, errorText } from "@/lib/api";
type Mode = "login" | "register" | "forgot";
@@ -178,7 +177,6 @@ export function PasswordLogin({
? "Ez a meghívó már nem érvényes, és ehhez a címhez sem tartozik másik."
: "A Sorsfonalak jelenleg meghívásos, és ehhez az e-mail-címhez nem tartozik meghívó. Ha kaptál meghívót, nyisd meg a levélben kapott linket."}
-
>
)}