This commit is contained in:
Jamie Brunton committed 2025-12-30 18:41:52 +00:00
1 parent d8f2f10418
commit c902763f9c
2 files changed
+20 -13

No files matched your search

+8 -6
View File
@@ -20,6 +20,7 @@ type AuditAction = 'INSERT' | 'UPDATE' | 'DELETE';
async function logAction(
tableName: string,
action: AuditAction,
recordId: string | null,
oldValues?: Record<string, unknown> | null,
newValues?: Record<string, unknown> | null
): Promise<void> {
@@ -29,6 +30,7 @@ async function logAction(
const { error } = await supabase.rpc('log_admin_action', {
p_table_name: tableName,
p_action: action,
p_record_id: recordId,
p_old_values: oldValues || null,
p_new_values: newValues || null,
});
@@ -72,7 +74,7 @@ export const auditedSupabase = {
if (!error && data) {
// Log each inserted record
for (const record of data as T[]) {
await logAction(table, 'INSERT', null, record as Record<string, unknown>);
await logAction(table, 'INSERT', record.id, null, record as Record<string, unknown>);
}
}
@@ -106,7 +108,7 @@ export const auditedSupabase = {
.single();
if (!error && data) {
await logAction(table, 'UPDATE', oldValues, data as Record<string, unknown>);
await logAction(table, 'UPDATE', id, oldValues, data as Record<string, unknown>);
}
return { data: data as T | null, error };
@@ -140,7 +142,7 @@ export const auditedSupabase = {
// Log each updated record
for (const record of data as T[]) {
const oldRecord = oldRecords.find(r => r.id === record.id);
await logAction(table, 'UPDATE', oldRecord || null, record as Record<string, unknown>);
await logAction(table, 'UPDATE', record.id, oldRecord || null, record as Record<string, unknown>);
}
}
@@ -171,7 +173,7 @@ export const auditedSupabase = {
.eq('id', id);
if (!error) {
await logAction(table, 'DELETE', oldValues, null);
await logAction(table, 'DELETE', id, oldValues, null);
}
return { error };
@@ -202,7 +204,7 @@ export const auditedSupabase = {
if (!error) {
// Log each deletion
for (const record of oldRecords) {
await logAction(table, 'DELETE', record, null);
await logAction(table, 'DELETE', record.id as string, record, null);
}
}
@@ -234,7 +236,7 @@ export const auditedSupabase = {
.eq(field, value);
if (!error && oldValues) {
await logAction(table, 'DELETE', oldValues, null);
await logAction(table, 'DELETE', (oldValues.id as string) || null, oldValues, null);
}
return { error };
+12 -7
View File
@@ -312,21 +312,26 @@ Mix distinct symmetric and asymmetric proposals.`;
export async function generateCategory(): Promise<{ name: string; description: string; icon: string }> {
const openai = getOpenAI();
const prompt = `Generate a unique category for organizing question packs in a couples' intimacy/connection app.
const prompt = `Generate a unique category for organizing activity packs in a couples' intimacy/connection app.
Return a JSON object with:
- name: Category name (1-3 words, e.g., "Romance", "Adventure", "Communication")
- description: Brief description of what packs in this category explore (1 sentence)
- icon: A single emoji that represents this category
This is an ACTIVITY-FOCUSED app where couples swipe on activity proposals.
Each partner independently swipes Like/Dislike/Maybe, and when both swipe positively they "match".
Categories organize collections of activity packs (date ideas, intimate experiences, adventures, challenges, etc.).
This is NOT a Q&A app - it's about discovering shared interests in activities.
Be creative and think of categories that help couples explore different aspects of their relationship.`;
Return a JSON object with:
- name: Category name (1-3 words, e.g., "Romance", "Adventure", "Date Nights")
- description: Brief description of what activity packs in this category contain (1 sentence)
- icon: A single emoji that represents this category
Be creative and think of categories that help couples explore different types of activities together.`;
const response = await openai.chat.completions.create({
model: getModel('generate'),
messages: [
{
role: 'system',
content: 'You are a creative content organizer for a couples relationship app. Generate engaging category ideas. Always respond with valid JSON only.',
content: 'You are a creative content organizer for a couples activity/intimacy app. The app helps couples discover shared interests by swiping on activity proposals. Generate engaging category ideas for organizing activity packs. Always respond with valid JSON only.',
},
{ role: 'user', content: prompt },
],