Skip to content

Commit

Permalink
Merge pull request #11107 from vegaprotocol/fix/reto-fill-should-use-…
Browse files Browse the repository at this point in the history
…transfers-current

fix: retro fill migration should use current transfers only
  • Loading branch information
guoguojin authored Apr 15, 2024
2 parents 59692c0 + e36dfe0 commit 70f2036
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ begin
for epoch in first_epoch..last_epoch-1 loop

INSERT INTO game_reward_totals(game_id, party_id, asset_id, market_id, team_id, total_rewards, total_rewards_quantum, epoch_id)
SELECT
SELECT DISTINCT -- we need distinct because the game ID is a hash of the dispatch metric on the transfer and these can be duplicated across multiple transfers when they are cancelled and replaced, or have been rejected at some point.
grto.game_id,
grto.party_id,
grto.asset_id,
Expand All @@ -29,7 +29,7 @@ begin
(grto.epoch_id + 1) AS epoch_id
FROM game_reward_totals AS grto
-- get the game end date from the transfer table and do not carry over rewards for games that have ended
JOIN transfers t on grto.game_id = t.game_id and t.end_epoch > grto.epoch_id
JOIN transfers_current t on grto.game_id = t.game_id and t.transfer_type = 'Recurring' and t.end_epoch > grto.epoch_id
WHERE grto.epoch_id = epoch
AND NOT EXISTS (
SELECT 1
Expand Down

0 comments on commit 70f2036

Please sign in to comment.