Index: database/drizzle/queries/builds.ts
===================================================================
--- database/drizzle/queries/builds.ts	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
+++ database/drizzle/queries/builds.ts	(revision 83fb5e20e4a24449997dabfce4e3017efabd0f4a)
@@ -46,5 +46,5 @@
 
 export async function setBuildApprovalStatus(db: Database, buildId: number, isApproved: boolean){
-    const result = await db
+    const [result] = await db
         .update(buildsTable)
         .set({
@@ -61,5 +61,5 @@
         })
 
-    return result.length;
+    return result?.id ?? null;
 }
 
@@ -135,5 +135,5 @@
             created_at: buildsTable.createdAt,
             total_price: buildsTable.totalPrice,
-            avgRating: sql<number>`AVG(${ratingBuildsTable.value}::float)`
+            avgRating: sql<number>`COALESCE(AVG(${ratingBuildsTable.value}::float),0)`
         })
         .from(buildsTable)
@@ -160,31 +160,4 @@
 
     return approvedBuildsList;
-}
-
-export async function getHighestRankedBuilds(db: Database, limit? : number) {
-    const highestRankedBuildsList = await db
-        .select({
-            id: buildsTable.id,
-            user_id: buildsTable.userId,
-            name: buildsTable.name,
-            created_at: buildsTable.createdAt,
-            total_price: buildsTable.totalPrice,
-            avgRating: sql<number>`AVG(${ratingBuildsTable.value}::float)`
-        })
-        .from(buildsTable)
-        .innerJoin(
-            ratingBuildsTable,
-            eq(buildsTable.id, ratingBuildsTable.buildId)
-        )
-        .where(
-            eq(buildsTable.isApproved, true)
-        )
-        .groupBy(buildsTable.id)
-        .orderBy(
-            desc(sql<number>`AVG(${ratingBuildsTable.value}::float)`)
-        )
-        .limit(limit || 100); // 100 placeholder
-
-    return highestRankedBuildsList;
 }
 
@@ -335,5 +308,5 @@
         .limit(1);
 
-    if (existing.length) {
+    if (existing.length > 0) {
         await db
             .delete(favoriteBuildsTable)
@@ -345,5 +318,5 @@
             );
 
-        return { favorite: false };
+        return null;
     }
 
@@ -355,5 +328,5 @@
         });
 
-    return { favorite: true };
+    return true;
 }
 
@@ -378,5 +351,5 @@
         })
 
-    return result;
+    return result ?? null;
 }
 
@@ -404,5 +377,5 @@
         })
 
-    return result;
+    return result ?? null;
 }
 
@@ -498,5 +471,5 @@
 
 export async function deleteBuild(db: Database, userId: number, buildId: number) {
-    const result = await db
+    const [result] = await db
         .delete(buildsTable)
         .where(
@@ -510,5 +483,5 @@
         })
 
-    return result.length;
+    return result?.id ?? null;
 }
 
@@ -550,5 +523,5 @@
         }
 
-        return newBuild.id;
+        return newBuild?.id ?? null;
     });
 }
