( page: number, limit: number )
| 134 | } |
| 135 | |
| 136 | export async function getRandomProjects( |
| 137 | page: number, |
| 138 | limit: number |
| 139 | ): Promise<Project[]> { |
| 140 | const supabase = getSupabaseClient(); |
| 141 | const { data, error } = await supabase |
| 142 | .from("projects") |
| 143 | .select("*") |
| 144 | .eq("status", ProjectStatus.Created) |
| 145 | .order("sort", { ascending: false }) |
| 146 | .order("created_at", { ascending: false }) |
| 147 | .range((page - 1) * limit, page * limit - 1); |
| 148 | |
| 149 | if (error) return []; |
| 150 | |
| 151 | return data.sort(() => Math.random() - 0.5); |
| 152 | } |
| 153 | |
| 154 | export async function getProjectsWithKeyword( |
| 155 | keyword: string, |
no test coverage detected