This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { sql } from 'bun'; | |
| async function fetch(categorySlug: string, sortBy: 'mostBenefitedFirst' | 'mostBenefitedLast') { | |
| const order = sortBy === 'mostBenefitedFirst' ? sql`ORDER BY diff DESC` : sql`ORDER BY diff ASC`; | |
| return await sql` | |
| SELECT | |
| e.slug, | |
| es.reviewApprovedCountAggregation, | |
| es.ratingAggregation, | |
| SUM(r.rating * (1 + (730 - LEAST(DATEDIFF(CURDATE(), r.firstPublishedAt), 730)) / 730)) / SUM(1 + (730 - LEAST(DATEDIFF(CURDATE(), r.firstPublishedAt), 730)) / 730) AS boostedRating, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "id": "c2c-friendly-question", | |
| "description": "Friendly consumer-to-consumer question about a review, clearly allowed.", | |
| "exchangeType": "consumer to consumer", | |
| "threadHistory": [], | |
| "message": { | |
| "body": "Hey, I saw your review about the washing machine. Has it still been working well after a year? I'm deciding whether to buy it.", | |
| "role": "consumer" | |
| }, |
OlderNewer