chore: normalize formatting
This commit is contained in:
parent
01ed2ac3b3
commit
2f6cfbe7ae
61 changed files with 921 additions and 743 deletions
|
@ -1,41 +1,41 @@
|
|||
import { createClient } from '@supabase/supabase-js'
|
||||
import { createClient } from "@supabase/supabase-js";
|
||||
|
||||
const SUPABASE_URL = process.env['SUPABASE_URL']
|
||||
const SUPABASE_KEY = process.env['SUPABASE_KEY']
|
||||
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
|
||||
const PAGE_SIZE = 1000
|
||||
const SUPABASE_URL = process.env["SUPABASE_URL"];
|
||||
const SUPABASE_KEY = process.env["SUPABASE_KEY"];
|
||||
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY);
|
||||
const PAGE_SIZE = 1000;
|
||||
|
||||
const fetchAllPosts = async () => {
|
||||
let posts = []
|
||||
let page = 0
|
||||
let fetchMore = true
|
||||
let posts = [];
|
||||
let page = 0;
|
||||
let fetchMore = true;
|
||||
|
||||
while (fetchMore) {
|
||||
const { data, error } = await supabase
|
||||
.from('optimized_posts')
|
||||
.select('*')
|
||||
.order('date', { ascending: false })
|
||||
.range(page * PAGE_SIZE, (page + 1) * PAGE_SIZE - 1)
|
||||
.from("optimized_posts")
|
||||
.select("*")
|
||||
.order("date", { ascending: false })
|
||||
.range(page * PAGE_SIZE, (page + 1) * PAGE_SIZE - 1);
|
||||
|
||||
if (error) {
|
||||
console.error('Error fetching posts:', error)
|
||||
return posts
|
||||
console.error("Error fetching posts:", error);
|
||||
return posts;
|
||||
}
|
||||
|
||||
if (data.length < PAGE_SIZE) fetchMore = false
|
||||
if (data.length < PAGE_SIZE) fetchMore = false;
|
||||
|
||||
posts = posts.concat(data)
|
||||
page++
|
||||
posts = posts.concat(data);
|
||||
page++;
|
||||
}
|
||||
|
||||
return posts
|
||||
}
|
||||
return posts;
|
||||
};
|
||||
|
||||
export default async function () {
|
||||
try {
|
||||
return await fetchAllPosts()
|
||||
return await fetchAllPosts();
|
||||
} catch (error) {
|
||||
console.error('Error fetching and processing posts:', error)
|
||||
return []
|
||||
console.error("Error fetching and processing posts:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue