mirror of
https://github.com/Hackdex-App/hackdex-website.git
synced 2026-10-19 22:28:50 -05:00
Hack page: let admins delete hacks, with an optional redirect (#108)
Some checks failed
Deploy Supabase Migrations to Production / migrate (push) Has been cancelled
Some checks failed
Deploy Supabase Migrations to Production / migrate (push) Has been cancelled
This commit is contained in:
@@ -72,7 +72,7 @@ export async function collectRecipients(supabase: SupabaseClient<Database>): Pro
|
||||
for (let offset = 0; ; offset += pageSize) {
|
||||
const { data, error } = await supabase.from("hacks")
|
||||
.select("slug,created_by,current_patch,patch_url,approved")
|
||||
.eq("is_archive", false).order("slug").range(offset, offset + pageSize - 1);
|
||||
.eq("is_archive", false).is("deleted_at", null).order("slug").range(offset, offset + pageSize - 1);
|
||||
if (error) throw new Error(`Cannot load hacks: ${error.message}`);
|
||||
if (!data) throw new Error("No response when loading hacks.");
|
||||
for (const hack of data) {
|
||||
|
||||
@@ -155,6 +155,7 @@ test("recipient selection paginates, excludes empty drafts, and deduplicates cre
|
||||
const url = new URL(new Request(input, init).url);
|
||||
if (url.pathname === "/rest/v1/hacks") {
|
||||
assert.equal(url.searchParams.get("is_archive"), "eq.false");
|
||||
assert.equal(url.searchParams.get("deleted_at"), "is.null");
|
||||
const columns = new Set(["slug", "created_by", "current_patch", "patch_url", "approved"]);
|
||||
const unknown = url.searchParams.get("select")?.split(",").find((column) => !columns.has(column));
|
||||
if (unknown) return Response.json({ message: `column hacks.${unknown} does not exist`, code: "42703" }, { status: 400 });
|
||||
|
||||
Reference in New Issue
Block a user