Skip to content

Commit

Permalink
chore: Drop redundant session folder
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Nov 6, 2023
1 parent f896564 commit 59c1faf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { gql } from "graphql-request";
import { subMonths } from "date-fns";

import { Operation, OperationResult, QueryResult } from "./types";
import { runSQL } from "../../../../hasura/schema";
import { getFilesForSession } from "../../../../session/files";
import { runSQL } from "../../../../lib/hasura/schema";
import { deleteFilesByURL } from "../../../../s3/deleteFile";
import { $api } from "../../../../client";
import { Passport } from "@opensystemslab/planx-core";

const RETENTION_PERIOD_MONTHS = 6;
export const getRetentionPeriod = () =>
Expand Down Expand Up @@ -97,7 +97,11 @@ export const deleteApplicationFiles: Operation = async () => {

const sessionIds = await getExpiredSessionIds();
for (const sessionId of sessionIds) {
const files = await getFilesForSession(sessionId);
const session = await $api.session.find(sessionId);
if (!session) {
throw Error(`Unable to find session matching id ${sessionId}`);
}
const files = new Passport(session.data.passport).files();
if (files.length) {
const deleted = await deleteFilesByURL(files);
deletedFiles.push(...deleted);
Expand Down
41 changes: 0 additions & 41 deletions api.planx.uk/session/files.test.ts

This file was deleted.

12 changes: 0 additions & 12 deletions api.planx.uk/session/files.ts

This file was deleted.

0 comments on commit 59c1faf

Please sign in to comment.