Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As API, I provide the possibility to fetch the jackpot rounds data #22

Open
melpadden opened this issue Mar 25, 2024 · 0 comments
Open
Assignees
Labels

Comments

@melpadden
Copy link
Collaborator

The API should be a simple https://expressjs.com/ application. For this task, the following endpoint should be added:

GET /rounds

That returns a paginated list of Round entities with the following properties:

  • round_id
  • plays_num
  • jackpot_amount
  • winner_account_hash
  • winner_public_key
  • ended_at

The jackpot data should be calculated over the plays table using a query like the following one which should be provided as getRounds(offset, limit) function in the Round repository:

select 
    p.round_id, 
    w.plays_num, 
    p.prize_amount as jackpot_amount, 
    p.player_account_hash as winner_account_hash, 
    p.timestamp as ended_at 
from plays p
join (
    select max(play_id) as play_id, count(*) as plays_num
    from plays 
    group by round_id
) w on w.play_id = p.play_id
order by p.round_id desc;

The winner_public_key should be deanonimized from the winner_account_hash in the API handler using CSPR.cloud Account API. Let’s implement it as a utility addPublicKeys(data, accountHashProperty, publicKeyProperty) because we’ll reuse it for three endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants