( supabase: SupabaseClient<Database>, groupId: string, )
| 870 | } |
| 871 | |
| 872 | async function getNextAnswerId( |
| 873 | supabase: SupabaseClient<Database>, |
| 874 | groupId: string, |
| 875 | ): Promise<string | null> { |
| 876 | // First, look for any unapproved answers in the same group |
| 877 | const { data: unapprovedData, error: unapprovedError } = await supabase |
| 878 | .from("approval_answers") |
| 879 | .select("id, group_id") |
| 880 | .match({ approved: false, is_generating: false }); |
| 881 | if (unapprovedError) throw new Error(unapprovedError.message); |
| 882 | if (unapprovedData.length) { |
| 883 | const nextUnapproved = unapprovedData.find( |
| 884 | (item) => item.group_id === groupId, |
| 885 | ); |
| 886 | console.log("nextUnapproved", nextUnapproved); |
| 887 | if (nextUnapproved) return nextUnapproved.id; |
| 888 | return unapprovedData[0].id; |
| 889 | } |
| 890 | return null; |
| 891 | } |
| 892 | |
| 893 | async function pullInMessageData( |
| 894 | answer_id: string, |
no outgoing calls
no test coverage detected