this repo has no description
1const { createClient } = require('@supabase/supabase-js')
2require('dotenv').config()
3
4const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL
5const supabaseKey = process.env.SUPABASE_SERVICE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
6
7const supabase = createClient(supabaseUrl, supabaseKey)
8
9async function checkTables() {
10 console.log('Checking table structure...\n')
11
12 // Check tweets table for streamed tweets
13 console.log('1. Checking tweets table for streamed tweets...')
14 const { data: streamedTweets, error: tweetsError } = await supabase
15 .from('tweets')
16 .select('created_at, tweet_id')
17 .is('archive_upload_id', null)
18 .order('created_at', { ascending: false })
19 .limit(5)
20
21 if (tweetsError) {
22 console.error('Error accessing tweets:', tweetsError)
23 } else {
24 console.log(`Found ${streamedTweets?.length || 0} streamed tweets`)
25 streamedTweets?.forEach(tweet => {
26 console.log(` - ${tweet.created_at}: ${tweet.tweet_id}`)
27 })
28 }
29
30 // Check if private.tweet_user exists and what columns it has
31 console.log('\n2. Checking private.tweet_user structure...')
32 console.log('Note: private.tweet_user is used for tracking scraped tweets, not streamed tweets')
33 console.log('For streamed tweets, we should use the tweets table directly')
34
35 // Count total streamed tweets
36 console.log('\n3. Counting total streamed tweets...')
37 const { count, error: countError } = await supabase
38 .from('tweets')
39 .select('tweet_id', { count: 'exact', head: true })
40 .is('archive_upload_id', null)
41
42 if (countError) {
43 console.error('Error counting tweets:', countError)
44 } else {
45 console.log(`Total streamed tweets: ${count}`)
46 }
47
48 // Get date range of streamed tweets
49 console.log('\n4. Getting date range of streamed tweets...')
50 const { data: minDate } = await supabase
51 .from('tweets')
52 .select('created_at')
53 .is('archive_upload_id', null)
54 .order('created_at', { ascending: true })
55 .limit(1)
56
57 const { data: maxDate } = await supabase
58 .from('tweets')
59 .select('created_at')
60 .is('archive_upload_id', null)
61 .order('created_at', { ascending: false })
62 .limit(1)
63
64 if (minDate && minDate[0] && maxDate && maxDate[0]) {
65 console.log(`Date range: ${minDate[0].created_at} to ${maxDate[0].created_at}`)
66 }
67}
68
69checkTables().catch(console.error)