-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathtest.js
43 lines (35 loc) · 1.32 KB
/
test.js
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
const ScreenshotService = require("./server/services/screenshotService");
const { supabaseClient } = require("./server/services/supabaseService");
const screenshotService = new ScreenshotService();
async function generateAllScreenshots() {
try {
// Fetch all ships from the Supabase table
const { data: ships, error } = await supabaseClient
.from('ships')
.select('slug')
.order('created_at', { ascending: false });
if (error) {
console.error("Error fetching ships:", error);
return;
}
console.log(`Found ${ships.length} ships. Generating screenshots...`);
// Generate screenshots for each ship
for (const ship of ships) {
try {
const filePath = await screenshotService.saveScreenshot(ship.slug);
console.log(`Generated screenshot for ${ship.slug}: ${filePath}`);
} catch (error) {
console.error(`Error generating screenshot for ${ship.slug}:`, error);
}
}
console.log("Finished generating all screenshots.");
} catch (error) {
console.error("Unexpected error:", error);
}
}
// Run the function to generate all screenshots
// generateAllScreenshots();
// Keep the original single screenshot generation for testing purposes
screenshotService.saveScreenshot("anuj-sharma-ZahGbgp6").then((filePath) => {
console.log(filePath);
});