mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-26 12:27:01 -05:00
Update submission_metadata queries
Enhance frontend to correctly fetch entity names by joining with submission_metadata and filtering metadata_key = 'name'; replace incorrect submission_metadata(name) usage in systemActivityService.ts and Profile.tsx with proper inner join and metadata_value extraction.
This commit is contained in:
@@ -368,7 +368,7 @@ export async function fetchSystemActivities(
|
||||
}
|
||||
|
||||
// Fetch submission reviews (approved/rejected submissions)
|
||||
// Note: Content is now in submission_metadata table, but entity_name is cached in view
|
||||
// Note: Content is now in submission_metadata table - need to join and filter properly
|
||||
const { data: submissions, error: submissionsError } = await supabase
|
||||
.from('content_submissions')
|
||||
.select(`
|
||||
@@ -377,8 +377,9 @@ export async function fetchSystemActivities(
|
||||
status,
|
||||
reviewer_id,
|
||||
reviewed_at,
|
||||
submission_metadata(name)
|
||||
submission_metadata!inner(metadata_value)
|
||||
`)
|
||||
.eq('submission_metadata.metadata_key', 'name')
|
||||
.not('reviewed_at', 'is', null)
|
||||
.in('status', ['approved', 'rejected', 'partially_approved'])
|
||||
.order('reviewed_at', { ascending: false })
|
||||
@@ -415,10 +416,10 @@ export async function fetchSystemActivities(
|
||||
);
|
||||
|
||||
for (const submission of submissions) {
|
||||
// Get name from submission_metadata
|
||||
// Get name from submission_metadata - extract metadata_value from the joined result
|
||||
const metadata = submission.submission_metadata as any;
|
||||
const entityName = Array.isArray(metadata) && metadata.length > 0
|
||||
? metadata[0]?.name
|
||||
? metadata[0]?.metadata_value
|
||||
: undefined;
|
||||
|
||||
const submissionItem = itemsMap.get(submission.id);
|
||||
|
||||
@@ -291,8 +291,9 @@ export default function Profile() {
|
||||
submission_type,
|
||||
status,
|
||||
created_at,
|
||||
submission_metadata(name)
|
||||
submission_metadata!inner(metadata_value)
|
||||
`)
|
||||
.eq('submission_metadata.metadata_key', 'name')
|
||||
.eq('user_id', userId)
|
||||
.order('created_at', { ascending: false })
|
||||
.limit(10);
|
||||
@@ -310,10 +311,10 @@ export default function Profile() {
|
||||
const enrichedSubmissions = await Promise.all((submissions || []).map(async (sub) => {
|
||||
const enriched: any = { ...sub };
|
||||
|
||||
// Get name from submission_metadata
|
||||
// Get name from submission_metadata - extract metadata_value from the joined result
|
||||
const metadata = sub.submission_metadata as any;
|
||||
enriched.name = Array.isArray(metadata) && metadata.length > 0
|
||||
? metadata[0]?.name
|
||||
? metadata[0]?.metadata_value
|
||||
: undefined;
|
||||
|
||||
// For photo submissions, get photo count and preview
|
||||
|
||||
Reference in New Issue
Block a user