reward errything again, fix reward parameters
This commit is contained in:
		
							parent
							
								
									d00de65e9b
								
							
						
					
					
						commit
						b0737e53d1
					
				@ -25,8 +25,8 @@ export default {
 | 
				
			|||||||
        WITH days_cte (day) AS (
 | 
					        WITH days_cte (day) AS (
 | 
				
			||||||
          SELECT date_trunc('day', t)
 | 
					          SELECT date_trunc('day', t)
 | 
				
			||||||
          FROM generate_series(
 | 
					          FROM generate_series(
 | 
				
			||||||
            COALESCE(${when?.[0]}::timestamp - interval '1 day', now() AT TIME ZONE 'America/Chicago'),
 | 
					            COALESCE(${when?.[0]}::text::timestamp - interval '1 day', now() AT TIME ZONE 'America/Chicago'),
 | 
				
			||||||
            COALESCE(${when?.[when.length - 1]}::timestamp - interval '1 day', now() AT TIME ZONE 'America/Chicago'),
 | 
					            COALESCE(${when?.[when.length - 1]}::text::timestamp - interval '1 day', now() AT TIME ZONE 'America/Chicago'),
 | 
				
			||||||
            interval '1 day') AS t
 | 
					            interval '1 day') AS t
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        SELECT coalesce(FLOOR(sum(sats)), 0) as total,
 | 
					        SELECT coalesce(FLOOR(sum(sats)), 0) as total,
 | 
				
			||||||
@ -82,8 +82,8 @@ export default {
 | 
				
			|||||||
        WITH days_cte (day) AS (
 | 
					        WITH days_cte (day) AS (
 | 
				
			||||||
          SELECT date_trunc('day', t)
 | 
					          SELECT date_trunc('day', t)
 | 
				
			||||||
          FROM generate_series(
 | 
					          FROM generate_series(
 | 
				
			||||||
            ${when[0]}::timestamp,
 | 
					            ${when[0]}::text::timestamp,
 | 
				
			||||||
            ${when[when.length - 1]}::timestamp,
 | 
					            ${when[when.length - 1]}::text::timestamp,
 | 
				
			||||||
            interval '1 day') AS t
 | 
					            interval '1 day') AS t
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        SELECT coalesce(sum(sats), 0) as total, json_agg("Earn".*) as rewards
 | 
					        SELECT coalesce(sum(sats), 0) as total, json_agg("Earn".*) as rewards
 | 
				
			||||||
 | 
				
			|||||||
@ -1,8 +1,8 @@
 | 
				
			|||||||
const serialize = require('../api/resolvers/serial')
 | 
					const serialize = require('../api/resolvers/serial')
 | 
				
			||||||
const { ANON_USER_ID } = require('../lib/constants')
 | 
					const { ANON_USER_ID } = require('../lib/constants')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// const ITEM_EACH_REWARD = 3.0
 | 
					const ITEM_EACH_REWARD = 4.0
 | 
				
			||||||
// const UPVOTE_EACH_REWARD = 6.0
 | 
					const UPVOTE_EACH_REWARD = 4.0
 | 
				
			||||||
const TOP_PERCENTILE = 33
 | 
					const TOP_PERCENTILE = 33
 | 
				
			||||||
const TOTAL_UPPER_BOUND_MSATS = 1000000000
 | 
					const TOTAL_UPPER_BOUND_MSATS = 1000000000
 | 
				
			||||||
const REDUCE_REWARDS = [616, 6030, 946, 4502]
 | 
					const REDUCE_REWARDS = [616, 6030, 946, 4502]
 | 
				
			||||||
@ -119,9 +119,13 @@ function earn ({ models }) {
 | 
				
			|||||||
          JOIN users on "userId" = users.id
 | 
					          JOIN users on "userId" = users.id
 | 
				
			||||||
          GROUP BY "userId", "parentId" IS NULL
 | 
					          GROUP BY "userId", "parentId" IS NULL
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
      SELECT "userId", id, type, rank, ratio/2.0 as proportion
 | 
					      SELECT "userId", NULL as id, type, ROW_NUMBER() OVER (PARTITION BY "isPost" ORDER BY upvoter_ratio DESC) as rank,
 | 
				
			||||||
      FROM item_ratios
 | 
					          upvoter_ratio/(sum(upvoter_ratio) OVER (PARTITION BY "isPost"))/${UPVOTE_EACH_REWARD} as proportion
 | 
				
			||||||
      ORDER BY type, rank ASC`
 | 
					      FROM upvoter_ratios
 | 
				
			||||||
 | 
					      WHERE upvoter_ratio > 0
 | 
				
			||||||
 | 
					      UNION ALL
 | 
				
			||||||
 | 
					      SELECT "userId", id, type, rank, ratio/${ITEM_EACH_REWARD} as proportion
 | 
				
			||||||
 | 
					      FROM item_ratios`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // in order to group earnings for users we use the same createdAt time for
 | 
					    // in order to group earnings for users we use the same createdAt time for
 | 
				
			||||||
    // all earnings
 | 
					    // all earnings
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user