Changeset 82aa6ae


Ignore:
Timestamp:
12/27/25 02:16:17 (7 months ago)
Author:
Tome <gjorgievtome@…>
Branches:
main
Children:
9854393
Parents:
dd5067a
Message:

fix getFavoriteBuildings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • database/drizzle/queries/builds.ts

    rdd5067a r82aa6ae  
    7777            name: buildsTable.name,
    7878            created_at: buildsTable.createdAt,
    79             total_price: buildsTable.totalPrice
     79            total_price: buildsTable.totalPrice,
     80            avgRating: sql<number>`COALESCE(AVG(${ratingBuildsTable.value}::float),0)`
    8081        })
    8182        .from(buildsTable)
     
    8485            eq(buildsTable.id, favoriteBuildsTable.buildId)
    8586        )
     87        .leftJoin(
     88            ratingBuildsTable,
     89            eq(buildsTable.id, ratingBuildsTable.buildId)
     90        )
    8691        .where(
    8792            eq(favoriteBuildsTable.userId, userId)
     93        )
     94        .groupBy(
     95            buildsTable.id,
     96            buildsTable.userId,
     97            buildsTable.name,
     98            buildsTable.createdAt,
     99            buildsTable.totalPrice
    88100        )
    89101        .orderBy(
Note: See TracChangeset for help on using the changeset viewer.