-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-posts.js
More file actions
66 lines (55 loc) · 1.68 KB
/
debug-posts.js
File metadata and controls
66 lines (55 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Debug script to check posts with location data
// Run this in the browser console on the map page to debug
console.log("🔍 DEBUG: Checking posts with location data...");
// Function to check posts in database
async function debugPosts() {
// Import supabase (this should work if run in browser console on the app)
const { supabase } = window;
if (!supabase) {
console.error("Supabase not available. Make sure you're on the VacayShare app page.");
return;
}
console.log("📊 Checking all posts...");
// Get all posts
const { data: allPosts, error: allError } = await supabase
.from('posts')
.select('*');
console.log("All posts:", allPosts, allError);
// Get posts with location data
const { data: postsWithLocation, error: locError } = await supabase
.from('posts')
.select(`
id,
created_at,
caption,
rating,
location_name,
latitude,
longitude,
visit_date,
user_id,
profiles:user_id (
username,
full_name,
avatar_url
)
`)
.not('latitude', 'is', null)
.not('longitude', 'is', null);
console.log("Posts with location:", postsWithLocation, locError);
// Check follows
const user = await supabase.auth.getUser();
if (user.data?.user) {
const { data: follows, error: followError } = await supabase
.from('follows')
.select('*')
.eq('follower_id', user.data.user.id);
console.log("Current user follows:", follows, followError);
}
}
// Run the debug
debugPosts().then(() => {
console.log("✅ Debug complete! Check the logs above.");
}).catch(error => {
console.error("❌ Debug failed:", error);
});