Skip to content

Commit 8ce55f2

Browse files
committed
Rename RETENTION_DAYS to OLD_FILE_THRESHOLD
1 parent b3e0d70 commit 8ce55f2

4 files changed

Lines changed: 12 additions & 15 deletions

File tree

app/api/files/views.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class FileDownloadView(
3535
- Download a specific file by its primary key.
3636
- Request the generation of a file for download by sending a message to a queue.
3737
- Delete a file manually from storage and database.
38-
- Automatically filter files older than FILE_RETENTION_DAYS from the list.
38+
- Automatically filter files older than OLD_FILE_THRESHOLD from the list.
3939
Attributes:
4040
serializer_class (Serializer): The serializer class used for file downloads.
4141
filter_backends (list): The list of filter backends for filtering querysets.
@@ -45,7 +45,7 @@ class FileDownloadView(
4545
Methods:
4646
get_queryset():
4747
Retrieves the queryset of FileDownload objects filtered by the scan report ID
48-
and age (files older than FILE_RETENTION_DAYS are excluded).
48+
and age (files older than OLD_FILE_THRESHOLD are excluded).
4949
get(request, *args, **kwargs):
5050
Handles GET requests. If a primary key is provided, it downloads the file.
5151
Otherwise, it returns a paginated list of files.
@@ -67,7 +67,7 @@ def get_queryset(self):
6767
scan_report = get_object_or_404(ScanReport, pk=scan_report_id)
6868

6969
# Return all non-deleted files
70-
# Frontend will handle hiding files older than FILE_RETENTION_DAYS
70+
# Frontend will handle hiding files older than OLD_FILE_THRESHOLD
7171
return FileDownload.objects.filter(
7272
scan_report=scan_report,
7373
deleted_at__isnull=True,
@@ -150,9 +150,7 @@ def post(self, request, *args, **kwargs):
150150
file_type_description = (
151151
"JSON V1"
152152
if file_type == "application/json_v1"
153-
else "JSON V2"
154-
if file_type == "application/json_v2"
155-
else "CSV"
153+
else "JSON V2" if file_type == "application/json_v2" else "CSV"
156154
)
157155
Job.objects.create(
158156
scan_report=ScanReport.objects.get(id=scan_report_id),

app/next-client-app/app/(protected)/scanreports/[id]/downloads/FileDownloadsTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ColumnDef } from "@tanstack/react-table";
55
import { DataTable } from "@/components/data-table";
66
import { Button } from "@/components/ui/button";
77
import { Eye, EyeOff } from "lucide-react";
8-
import { FILE_RETENTION_DAYS } from "@/constants/config";
8+
import { OLD_FILE_THRESHOLD } from "@/constants/config";
99

1010
interface FileDownloadsTableProps {
1111
data: FileDownload[];
@@ -26,7 +26,7 @@ export function FileDownloadsTable({
2626

2727
const cutoffDate = useMemo(() => {
2828
const millisecondsPerDay = 24 * 60 * 60 * 1000;
29-
return new Date(Date.now() - FILE_RETENTION_DAYS * millisecondsPerDay);
29+
return new Date(Date.now() - OLD_FILE_THRESHOLD * millisecondsPerDay);
3030
}, []);
3131

3232
const { recentFiles, oldFiles } = useMemo(() => {

app/next-client-app/constants/config.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ const MAX_FILE_SIZE_BYTES = process.env.NEXT_PUBLIC_BODY_SIZE_LIMIT
33
? parseInt(process.env.NEXT_PUBLIC_BODY_SIZE_LIMIT, 10)
44
: 31457280; // 30MB in bytes
55

6-
// File retention period in days (configurable via env, default 6 hours for testing)
7-
// 6 hours = 0.25 days
8-
const FILE_RETENTION_DAYS = process.env.NEXT_PUBLIC_FILE_RETENTION_DAYS
9-
? parseFloat(process.env.NEXT_PUBLIC_FILE_RETENTION_DAYS)
10-
: 0.25;
6+
// Old file threshold in days - files older than this are auto-hidden in the UI
7+
const OLD_FILE_THRESHOLD = process.env.NEXT_PUBLIC_OLD_FILE_THRESHOLD
8+
? parseFloat(process.env.NEXT_PUBLIC_OLD_FILE_THRESHOLD)
9+
: 30;
1110

1211
module.exports = {
1312
MAX_FILE_SIZE_BYTES,
14-
FILE_RETENTION_DAYS,
13+
OLD_FILE_THRESHOLD,
1514
};

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ services:
7777
- RECOMMENDATION_SERVICE_BASE_URL=https://api.hyperunison.com/api/public/suggester/generate
7878
- RECOMMENDATION_SERVICE_API_KEY=unison-api-key
7979
- NEXT_PUBLIC_BODY_SIZE_LIMIT=31457280
80-
- NEXT_PUBLIC_FILE_RETENTION_DAYS=30
80+
- NEXT_PUBLIC_OLD_FILE_THRESHOLD=30
8181
volumes:
8282
- ./app/next-client-app:/app
8383
- /app/node_modules

0 commit comments

Comments
 (0)