diff --git a/netlify/functions/batchUpdateMeetingSummariesArray.js b/netlify/functions/batchUpdateMeetingSummariesArray.js index b773c31..9abb592 100644 --- a/netlify/functions/batchUpdateMeetingSummariesArray.js +++ b/netlify/functions/batchUpdateMeetingSummariesArray.js @@ -2,44 +2,25 @@ import { supabase } from '../../lib/supabaseClient'; import { Octokit } from "@octokit/rest"; -const BATCH_SIZE = 100; - export const handler = async (event, context) => { try { - let allSummaries = []; - let lastProcessedTimestamp = null; - let hasMoreSummaries = true; - - while (hasMoreSummaries) { - // Retrieve the next batch of summaries - let { data: summaries, error } = await supabase - .from('meetingsummaries') - .select('meeting_id, created_at, summary') - .order('created_at', { ascending: true }) - .limit(BATCH_SIZE); + // Retrieve all summaries + const { data: summaries, error } = await supabase + .from('meetingsummaries') + .select('meeting_id, created_at, summary') + .order('created_at', { ascending: true }); - if (lastProcessedTimestamp) { - summaries = summaries.filter(summary => summary.created_at > lastProcessedTimestamp); - } - - if (error) { - console.error('Error retrieving meeting summaries:', error); - return { - statusCode: 500, - body: JSON.stringify({ error: 'Failed to retrieve meeting summaries' }), - }; - } - - if (summaries.length === 0) { - hasMoreSummaries = false; - break; - } - - // Accumulate the summaries - allSummaries = allSummaries.concat(summaries.map(summary => summary.summary)); - lastProcessedTimestamp = summaries[summaries.length - 1].created_at; + if (error) { + console.error('Error retrieving meeting summaries:', error); + return { + statusCode: 500, + body: JSON.stringify({ error: 'Failed to retrieve meeting summaries' }), + }; } + // Extract summaries from the retrieved data + const allSummaries = summaries.map(summary => summary.summary); + // Commit all summaries to GitHub in a single file const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN,