fix lastCommentAt denorm
This commit is contained in:
		
							parent
							
								
									63e60fe2bc
								
							
						
					
					
						commit
						9145f290dc
					
				@ -197,7 +197,7 @@ export async function onPaid ({ invoice, id }, context) {
 | 
				
			|||||||
  // TODO: referals for boost
 | 
					  // TODO: referals for boost
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (item.parentId) {
 | 
					  if (item.parentId) {
 | 
				
			||||||
    // denormalize ncomments and "weightedComments" for ancestors, and insert into reply table
 | 
					    // denormalize ncomments, lastCommentAt, and "weightedComments" for ancestors, and insert into reply table
 | 
				
			||||||
    await tx.$executeRaw`
 | 
					    await tx.$executeRaw`
 | 
				
			||||||
      WITH comment AS (
 | 
					      WITH comment AS (
 | 
				
			||||||
        SELECT *
 | 
					        SELECT *
 | 
				
			||||||
@ -206,6 +206,7 @@ export async function onPaid ({ invoice, id }, context) {
 | 
				
			|||||||
      ), ancestors AS (
 | 
					      ), ancestors AS (
 | 
				
			||||||
        UPDATE "Item"
 | 
					        UPDATE "Item"
 | 
				
			||||||
        SET ncomments = "Item".ncomments + 1,
 | 
					        SET ncomments = "Item".ncomments + 1,
 | 
				
			||||||
 | 
					          "lastCommentAt" = now(),
 | 
				
			||||||
          "weightedComments" = "Item"."weightedComments" +
 | 
					          "weightedComments" = "Item"."weightedComments" +
 | 
				
			||||||
            CASE WHEN comment."userId" = "Item"."userId" THEN 0 ELSE ${item.user.trust}::FLOAT END
 | 
					            CASE WHEN comment."userId" = "Item"."userId" THEN 0 ELSE ${item.user.trust}::FLOAT END
 | 
				
			||||||
        FROM comment
 | 
					        FROM comment
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user