Last active
September 5, 2025 08:56
-
-
Save danielberndt/3899cdbcb48b49dd069acef87115cb65 to your computer and use it in GitHub Desktop.
Revisions
-
danielberndt revised this gist
Sep 5, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // delete any file no matter if used as attachment or not (filtered by date and file size) void (async () => { const subdomain = window.location.host.split(".")[0] -
danielberndt revised this gist
Sep 5, 2025 . 2 changed files with 44 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ // delete non-attachment files (filtered by date and file size) void (async () => { const subdomain = window.location.host.split(".")[0] const fileQuery = { createdAt: { op: "lt", value: "2024-09-04" }, isDeleted: false, selfHosted: true, size: {op: "gt", value: 1000000}, $order: "createdAt", $limit: 100 }; // build up the nested query and define which models and fields we want to receive const query = { _root: [ { account: [ { [`files(${JSON.stringify(fileQuery)})`]: [ "id" ], }, ], }, ], }; // pass the query to the api const data = await fetch( `https://api.codecks.io?query=${JSON.stringify( query )}&x-account=${subdomain}`, { credentials: "include" } ).then((r) => r.json()); // parse the response and create delete request const files = Object.values(data.file) const body = {ids: files.map(f => f.id)} await fetch( `https://api.codecks.io/dispatch/attachments/batchDeleteByFileId?&x-account=${subdomain}`, { credentials: "include", method: "POST", body: JSON.stringify(body), headers: {"Content-Type": "application/json"} } ) })() -
danielberndt revised this gist
Sep 4, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ void (async () => { const subdomain = window.location.host.split(".")[0] const attachmentQuery = { createdAt: { op: "lt", value: "2024-09-04" }, file: { -
danielberndt revised this gist
Sep 4, 2025 . No changes.There are no files selected for viewing
-
danielberndt created this gist
Sep 4, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ void (async () => { const subdomain = "MYSUBDOMAIN"; // for e.g. MYSUBDOMAIN.codecks.io const attachmentQuery = { createdAt: { op: "lt", value: "2024-09-04" }, file: { isDeleted: false, selfHosted: true, }, $order: "createdAt", $limit: 100 }; // build up the nested query and define which models and fields we want to receive const query = { _root: [ { account: [ { [`attachments(${JSON.stringify(attachmentQuery)})`]: [ { file: ["id"] }, ], }, ], }, ], }; // pass the query to the api const data = await fetch( `https://api.codecks.io?query=${JSON.stringify( query )}&x-account=${subdomain}`, { credentials: "include" } ).then((r) => r.json()); const attachments = Object.values(data.attachment) const body = {ids: attachments.map(a => a.id), fileIds: attachments.map(a => a.file)} await fetch( `https://api.codecks.io/dispatch/attachments/batchDeleteFile?&x-account=${subdomain}`, { credentials: "include", method: "POST", body: JSON.stringify(body), headers: {"Content-Type": "application/json"} } ) })()