|
2 | 2 | import { supabase } from '../../lib/supabaseClient'; |
3 | 3 | import { Octokit } from "@octokit/rest"; |
4 | 4 |
|
5 | | -const BATCH_SIZE = 100; |
6 | | - |
7 | 5 | export const handler = async (event, context) => { |
8 | 6 | try { |
9 | | - let allSummaries = []; |
10 | | - let lastProcessedTimestamp = null; |
11 | | - let hasMoreSummaries = true; |
12 | | - |
13 | | - while (hasMoreSummaries) { |
14 | | - // Retrieve the next batch of summaries |
15 | | - let { data: summaries, error } = await supabase |
16 | | - .from('meetingsummaries') |
17 | | - .select('meeting_id, created_at, summary') |
18 | | - .order('created_at', { ascending: true }) |
19 | | - .limit(BATCH_SIZE); |
| 7 | + // Retrieve all summaries |
| 8 | + const { data: summaries, error } = await supabase |
| 9 | + .from('meetingsummaries') |
| 10 | + .select('meeting_id, created_at, summary') |
| 11 | + .order('created_at', { ascending: true }); |
20 | 12 |
|
21 | | - if (lastProcessedTimestamp) { |
22 | | - summaries = summaries.filter(summary => summary.created_at > lastProcessedTimestamp); |
23 | | - } |
24 | | - |
25 | | - if (error) { |
26 | | - console.error('Error retrieving meeting summaries:', error); |
27 | | - return { |
28 | | - statusCode: 500, |
29 | | - body: JSON.stringify({ error: 'Failed to retrieve meeting summaries' }), |
30 | | - }; |
31 | | - } |
32 | | - |
33 | | - if (summaries.length === 0) { |
34 | | - hasMoreSummaries = false; |
35 | | - break; |
36 | | - } |
37 | | - |
38 | | - // Accumulate the summaries |
39 | | - allSummaries = allSummaries.concat(summaries.map(summary => summary.summary)); |
40 | | - lastProcessedTimestamp = summaries[summaries.length - 1].created_at; |
| 13 | + if (error) { |
| 14 | + console.error('Error retrieving meeting summaries:', error); |
| 15 | + return { |
| 16 | + statusCode: 500, |
| 17 | + body: JSON.stringify({ error: 'Failed to retrieve meeting summaries' }), |
| 18 | + }; |
41 | 19 | } |
42 | 20 |
|
| 21 | + // Extract summaries from the retrieved data |
| 22 | + const allSummaries = summaries.map(summary => summary.summary); |
| 23 | + |
43 | 24 | // Commit all summaries to GitHub in a single file |
44 | 25 | const octokit = new Octokit({ |
45 | 26 | auth: process.env.GITHUB_TOKEN, |
|
0 commit comments