Skip to content

Commit

Permalink
V.0.3.1.6 🌶️ Hotfixes (#35)
Browse files Browse the repository at this point in the history
* Fixed filtering only returning 1 row

* Hotfix: Revalidate cache after 10s

Added cache revalidation after 10s to fix data being cached permanently
  • Loading branch information
xKhronoz authored May 20, 2024
1 parent b6915e6 commit f8ff91f
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 19 deletions.
7 changes: 4 additions & 3 deletions frontend/app/api/admin/collections-requests/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const dynamic = 'force-dynamic';
export const revalidate = 10;

import { createClient } from '@supabase/supabase-js';
import { NextRequest, NextResponse } from "next/server";
Expand Down Expand Up @@ -34,14 +34,15 @@ export async function GET(request: NextRequest) {
)
)
`)
.eq('is_pending', true);
.eq('is_pending', true)
.limit(1000);

if (collErr) {
console.error('Error fetching collection request data from database:', collErr.message);
return NextResponse.json({ error: collErr.message }, { status: 500 });
}

// console.log('Collections Request:', collectionsReq);
// console.log('New Collections Request:', collectionsReq);

return NextResponse.json({ collectionsReq: collectionsReq });
}
2 changes: 1 addition & 1 deletion frontend/app/api/admin/collections/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const dynamic = 'force-dynamic';
export const revalidate = 10;

import { createClient } from '@supabase/supabase-js';
import { NextRequest, NextResponse } from "next/server";
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/api/admin/users/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const dynamic = 'force-dynamic';
export const revalidate = 10;

import { createClient } from '@supabase/supabase-js';
import { NextRequest, NextResponse } from "next/server";
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/api/public/collections/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const dynamic = 'force-dynamic';
export const revalidate = 10;

import { createClient } from '@supabase/supabase-js';
import { NextRequest, NextResponse } from "next/server";
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/api/user/collections-requests/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const dynamic = 'force-dynamic';
export const revalidate = 10;

import { createClient } from '@supabase/supabase-js';
import { NextRequest, NextResponse } from "next/server";
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/api/user/collections/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const dynamic = 'force-dynamic';
export const revalidate = 10;

import { createClient } from '@supabase/supabase-js';
import { NextRequest, NextResponse } from "next/server";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default function AdminManageCollections() {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable cache to get the latest data
},
}
);
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/components/ui/admin/admin-manage-requests.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"use client";

import { unstable_noStore as noStore } from 'next/cache';
import { useEffect, useState } from 'react';
import { Eye, EyeOff, X, Check, RefreshCw } from 'lucide-react';
import { IconSpinner } from '@/app/components/ui/icons';
import { toast } from 'react-toastify';
import Swal from 'sweetalert2';

export default function AdminManageRequests() {
noStore();
const [userRequests, setUserRequests] = useState<any[]>([]);
const [loading, setLoading] = useState<boolean>(true);
const [isRefreshed, setIsRefreshed] = useState<boolean>(true); // Track whether the data has been refreshed
Expand All @@ -20,7 +22,6 @@ export default function AdminManageRequests() {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable cache to get the latest data
},
}
);
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/components/ui/admin/admin-manage-users.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"use client";

import { unstable_noStore as noStore } from 'next/cache';
import { useEffect, useState } from "react";
import { toast } from "react-toastify";
import { RefreshCw, UserCheck, UserX } from "lucide-react";
import { IconSpinner } from "@/app/components/ui/icons";
import Swal from "sweetalert2";

export default function AdminManageUsers() {
noStore();
const [users, setUsers] = useState<any[]>([]);
const [loading, setLoading] = useState<boolean>(true);
const [isRefreshed, setIsRefreshed] = useState<boolean>(true); // Track whether the data has been refreshed
Expand All @@ -20,7 +22,6 @@ export default function AdminManageUsers() {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable cache to get the latest data
},
}
);
Expand Down
1 change: 0 additions & 1 deletion frontend/app/components/ui/chat/chat-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default function ChatSelection(
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable caching
},
});

Expand Down
5 changes: 0 additions & 5 deletions frontend/app/components/ui/query/query-manage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default function QueryCollectionManage() {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable caching
},
}
)
Expand Down Expand Up @@ -125,7 +124,6 @@ export default function QueryCollectionManage() {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable caching
},
body: JSON.stringify({ collection_id: collectionId, is_make_public: isPublic }),
}
Expand Down Expand Up @@ -177,7 +175,6 @@ export default function QueryCollectionManage() {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable caching
},
body: JSON.stringify({ collection_id: collectionId, is_make_public: isPublic }),
}
Expand Down Expand Up @@ -246,7 +243,6 @@ export default function QueryCollectionManage() {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable caching
},
body: JSON.stringify({ collection_id: collectionId }),
}
Expand Down Expand Up @@ -314,7 +310,6 @@ export default function QueryCollectionManage() {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable caching
'Authorization': `Bearer ${supabaseAccessToken}`, // Add the access token to the request headers
},
body: JSON.stringify({ collection_id: collectionId }),
Expand Down
1 change: 0 additions & 1 deletion frontend/app/components/ui/query/query-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default function QuerySelection(
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable caching
},
});

Expand Down
1 change: 0 additions & 1 deletion frontend/app/components/ui/search/search-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default function SearchSelection(
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache', // Disable caching
},
});

Expand Down

0 comments on commit f8ff91f

Please sign in to comment.