Commit a3ef5242 authored by duanjinfei's avatar duanjinfei

fix cache recommend data

parent c24687d9
......@@ -14,9 +14,11 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
while (true) {
const { data, error } = await supabase
.from(table)
.select('id,name,icon,description,points,category_id,link,images,appPlatforms,caption,is_forward,is_show') // 可以根据需要调整字段
.select('id,name,icon,description,points,category_id,link,images,appPlatforms,caption,is_forward,is_show,recommend') // 可以根据需要调整字段
.gt('is_show', 0)
.gt('recommend', 0)
// .eq('is_show', 1)
.order('recommend', { ascending: false })
.order('created_at', { ascending: true }) // 按照创建时间排序
.range(offset, offset + pageSize - 1); // 分页范围
......@@ -88,12 +90,12 @@ async function cacheTaskCount(supabase, directory, bucketName) {
async function cacheRecommendApp(supabase, allApps, directory, bucketName) {
const recommendPageSize = 3;
const recommendApps = allApps.filter(app => app.recommend > 0)
.sort((a, b) => b.recommend - a.recommend); // 按 recommend 字段降序排序
const recommendTotalCount = recommendApps.length;
// const recommendApps = allApps.filter(app => app.recommend > 0)
// .sort((a, b) => b.recommend - a.recommend); // 按 recommend 字段降序排序
const recommendTotalCount = allApps.length;
const recommendPaginatedApps = [];
for (let i = 0; i < recommendTotalCount; i += recommendPageSize) {
recommendPaginatedApps.push(recommendApps.slice(i, i + recommendPageSize));
recommendPaginatedApps.push(allApps.slice(i, i + recommendPageSize));
}
console.log("total page:", recommendPaginatedApps.length);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment