Changeset 9854393 for database/drizzle/queries/builds.ts
- Timestamp:
- 12/27/25 02:27:36 (7 months ago)
- Branches:
- main
- Children:
- ad311c3
- Parents:
- 82aa6ae
- File:
-
- 1 edited
-
database/drizzle/queries/builds.ts (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
database/drizzle/queries/builds.ts
r82aa6ae r9854393 108 108 export async function getApprovedBuilds(db: Database, limit?: number, sort?: string, q?: string) { 109 109 let queryConditions = [eq(buildsTable.isApproved, true)]; 110 let sortCondition s = [];110 let sortCondition:any; 111 111 112 112 if (q) { … … 118 118 switch(sort) { 119 119 case 'price_asc': 120 sortConditions.push( 121 asc(buildsTable.totalPrice) 122 ); 120 sortCondition = asc(buildsTable.totalPrice) 123 121 break; 124 122 case 'price_desc': 125 sortConditions.push( 126 desc(buildsTable.totalPrice) 127 ); 123 sortCondition = desc(buildsTable.totalPrice) 128 124 break; 129 125 case 'rating_desc': 130 sortConditions.push( 131 desc(sql<number>`COALESCE(AVG(${ratingBuildsTable.value}::float),0)`) 132 ); 126 sortCondition = desc(sql<number>`COALESCE(AVG(${ratingBuildsTable.value}::float),0)`) 133 127 break; 134 128 case 'oldest': 135 sortConditions.push( 136 asc(buildsTable.createdAt) 137 ); 129 sortCondition = asc(buildsTable.createdAt) 138 130 break; 139 131 case 'newest': 140 sortConditions.push( 141 desc(buildsTable.createdAt) 142 ); 132 sortCondition = desc(buildsTable.createdAt) 143 133 break; 144 134 default: 145 sortConditions.push( 146 desc(buildsTable.createdAt) 147 ); 135 sortCondition = desc(buildsTable.createdAt) 148 136 break; 149 137 } … … 176 164 ) 177 165 .orderBy( 178 ...sortConditions166 sortCondition 179 167 ) 180 168 .limit(limit || 100); // 100 placeholder
Note:
See TracChangeset
for help on using the changeset viewer.
