Fix recent sort order for retried items (#1829)
* Fix recent sort order for retried items * Also fix for comments * don't hide createdAt, order item query inner subquery --------- Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com> Co-authored-by: k00b <k00b@stacker.news>
This commit is contained in:
		
							parent
							
								
									ae1942ada7
								
							
						
					
					
						commit
						ca7726fda5
					
				@ -26,7 +26,7 @@ import { verifyHmac } from './wallet'
 | 
			
		||||
 | 
			
		||||
function commentsOrderByClause (me, models, sort) {
 | 
			
		||||
  if (sort === 'recent') {
 | 
			
		||||
    return 'ORDER BY ("Item"."deletedAt" IS NULL) DESC, ("Item".cost > 0 OR "Item"."weightedVotes" - "Item"."weightedDownVotes" > 0) DESC, "Item".created_at DESC, "Item".id DESC'
 | 
			
		||||
    return 'ORDER BY ("Item"."deletedAt" IS NULL) DESC, ("Item".cost > 0 OR "Item"."weightedVotes" - "Item"."weightedDownVotes" > 0) DESC, COALESCE("Item"."invoicePaidAt", "Item".created_at) DESC, "Item".id DESC'
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (me && sort === 'hot') {
 | 
			
		||||
@ -412,10 +412,10 @@ export default {
 | 
			
		||||
                typeClause(type),
 | 
			
		||||
                muteClause(me)
 | 
			
		||||
              )}
 | 
			
		||||
              ORDER BY "Item".created_at DESC
 | 
			
		||||
              ORDER BY COALESCE("Item"."invoicePaidAt", "Item".created_at) DESC
 | 
			
		||||
              OFFSET $2
 | 
			
		||||
              LIMIT $3`,
 | 
			
		||||
            orderBy: 'ORDER BY "Item"."createdAt" DESC'
 | 
			
		||||
            orderBy: 'ORDER BY COALESCE("Item"."invoicePaidAt", "Item".created_at) DESC'
 | 
			
		||||
          }, decodedCursor.time, decodedCursor.offset, limit, ...subArr)
 | 
			
		||||
          break
 | 
			
		||||
        case 'top':
 | 
			
		||||
 | 
			
		||||
@ -107,6 +107,7 @@ export default gql`
 | 
			
		||||
    id: ID!
 | 
			
		||||
    createdAt: Date!
 | 
			
		||||
    updatedAt: Date!
 | 
			
		||||
    invoicePaidAt: Date
 | 
			
		||||
    deletedAt: Date
 | 
			
		||||
    deleteScheduledAt: Date
 | 
			
		||||
    reminderScheduledAt: Date
 | 
			
		||||
 | 
			
		||||
@ -135,8 +135,8 @@ export default function ItemInfo ({
 | 
			
		||||
            {embellishUser}
 | 
			
		||||
          </Link>}
 | 
			
		||||
        <span> </span>
 | 
			
		||||
        <Link href={`/items/${item.id}`} title={item.createdAt} className='text-reset' suppressHydrationWarning>
 | 
			
		||||
          {timeSince(new Date(item.createdAt))}
 | 
			
		||||
        <Link href={`/items/${item.id}`} title={item.invoicePaidAt || item.createdAt} className='text-reset' suppressHydrationWarning>
 | 
			
		||||
          {timeSince(new Date(item.invoicePaidAt || item.createdAt))}
 | 
			
		||||
        </Link>
 | 
			
		||||
        {item.prior &&
 | 
			
		||||
          <>
 | 
			
		||||
@ -250,6 +250,11 @@ function InfoDropdownItem ({ item }) {
 | 
			
		||||
          <div>{item.id}</div>
 | 
			
		||||
          <div>created at</div>
 | 
			
		||||
          <div>{item.createdAt}</div>
 | 
			
		||||
          {item.invoicePaidAt &&
 | 
			
		||||
            <>
 | 
			
		||||
              <div>paid at</div>
 | 
			
		||||
              <div>{item.invoicePaidAt}</div>
 | 
			
		||||
            </>}
 | 
			
		||||
          <div>cost</div>
 | 
			
		||||
          <div>{item.cost}</div>
 | 
			
		||||
          <div>stacked</div>
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,7 @@ export const COMMENT_FIELDS = gql`
 | 
			
		||||
    position
 | 
			
		||||
    parentId
 | 
			
		||||
    createdAt
 | 
			
		||||
    invoicePaidAt
 | 
			
		||||
    deletedAt
 | 
			
		||||
    text
 | 
			
		||||
    user {
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,7 @@ export const ITEM_FIELDS = gql`
 | 
			
		||||
    id
 | 
			
		||||
    parentId
 | 
			
		||||
    createdAt
 | 
			
		||||
    invoicePaidAt
 | 
			
		||||
    deletedAt
 | 
			
		||||
    title
 | 
			
		||||
    url
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,3 @@
 | 
			
		||||
-- CreateIndex
 | 
			
		||||
CREATE INDEX "Item_invoicePaidAt_idx" ON "Item"("invoicePaidAt");
 | 
			
		||||
CREATE INDEX "Item_paid_created_idx" ON "Item" (COALESCE("invoicePaidAt", created_at) DESC);
 | 
			
		||||
@ -598,6 +598,7 @@ model Item {
 | 
			
		||||
  @@index([cost])
 | 
			
		||||
  @@index([url])
 | 
			
		||||
  @@index([boost])
 | 
			
		||||
  @@index([invoicePaidAt])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// we use this to denormalize a user's aggregated interactions (zaps) with an item
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user