@@ -192,7 +192,7 @@ export default async function SharedCapsPage(props: {
192192 totalComments : sql < number > `COUNT(DISTINCT CASE WHEN ${ comments . type } = 'text' THEN ${ comments . id } END)` ,
193193 totalReactions : sql < number > `COUNT(DISTINCT CASE WHEN ${ comments . type } = 'emoji' THEN ${ comments . id } END)` ,
194194 ownerName : users . name ,
195- effectiveDate : sql < string > `COALESCE(JSON_UNQUOTE(JSON_EXTRACT( ${ videos . metadata } , '$.customCreatedAt')), ${ videos . createdAt } )` ,
195+ effectiveDate : videos . effectiveCreatedAt ,
196196 hasActiveUpload : sql `${ videoUploads . videoId } IS NOT NULL` . mapWith (
197197 Boolean ,
198198 ) ,
@@ -218,11 +218,7 @@ export default async function SharedCapsPage(props: {
218218 videos . metadata ,
219219 users . name ,
220220 )
221- . orderBy (
222- desc (
223- sql `COALESCE(JSON_UNQUOTE(JSON_EXTRACT(${ videos . metadata } , '$.customCreatedAt')), ${ videos . createdAt } )` ,
224- ) ,
225- )
221+ . orderBy ( desc ( videos . effectiveCreatedAt ) )
226222 . limit ( limit )
227223 . offset ( offset ) ,
228224 db ( )
@@ -292,7 +288,7 @@ export default async function SharedCapsPage(props: {
292288 totalComments : sql < number > `COUNT(DISTINCT CASE WHEN ${ comments . type } = 'text' THEN ${ comments . id } END)` ,
293289 totalReactions : sql < number > `COUNT(DISTINCT CASE WHEN ${ comments . type } = 'emoji' THEN ${ comments . id } END)` ,
294290 ownerName : users . name ,
295- effectiveDate : sql < string > `COALESCE(JSON_UNQUOTE(JSON_EXTRACT( ${ videos . metadata } , '$.customCreatedAt')), ${ videos . createdAt } )` ,
291+ effectiveDate : videos . effectiveCreatedAt ,
296292 hasActiveUpload : sql `${ videoUploads . videoId } IS NOT NULL` . mapWith (
297293 Boolean ,
298294 ) ,
@@ -317,11 +313,7 @@ export default async function SharedCapsPage(props: {
317313 users . name ,
318314 videos . duration ,
319315 )
320- . orderBy (
321- desc (
322- sql `COALESCE(JSON_UNQUOTE(JSON_EXTRACT(${ videos . metadata } , '$.customCreatedAt')), ${ videos . createdAt } )` ,
323- ) ,
324- )
316+ . orderBy ( desc ( videos . effectiveCreatedAt ) )
325317 . limit ( limit )
326318 . offset ( offset ) ,
327319 db ( )
0 commit comments