Bounties-Network / BountiesAPI

The caching layer of the Bounties Network
MIT License
44 stars 26 forks source link

Feature: Analytics Endpoint V1 #3

Closed villanuevawill closed 6 years ago

villanuevawill commented 6 years ago

This is the first bounty in an upcoming set of bounties focused around building an analytics dashboard for projects that utilize the standard bounties contract such as gitcoin, and other upcoming open source sites.

This first task begins the work of exposing endpoints around daily stats for a range of time. Ultimately, these will be used to build a react frontend connected to highcharts or other charting libraries. The data is already stored in PSQL, it just needs to be served up via the format requested below. This task ultimately requires just one endpoint to be built for now.

Requirements

Statistics

All of the above should be a separate field on one model that the job writes to. For the current day, this should be calculated in realtime. These should all be exposed on one api endpoint.

Definition of Done

Reviewers

Myself and @mbeylin

Review Requirements

gitcoinbot commented 6 years ago

This issue now has a funding of 0.33 ETH (177.45 USD @ $537.71/ETH) attached to it.

leonprou commented 6 years ago

Hey I like this feature, I started working in a draft, can you check that I understood the solution correctly? Mostly the models.py file. My fork: https://github.com/leonprou/BountiesAPI/tree/analytics_endpoint

villanuevawill commented 6 years ago

@leonprou just looked through it - looks like the right direction. publish_date might be clearer as just date or stats_date, etc... but yeah direction looks right.

leonprou commented 6 years ago

@villanuevawill cool , thanks for quick response 👍 I've thought a little about the job. I have a question about it, when I create a statistics for some day, is this statistics object is immutable? Can some event happen that will require recalculate the statistics for that day? For example if some bounty changes its stage from Draft to Active, the "Number of bounties in each bountyStage" needs to be recalculated.

villanuevawill commented 6 years ago

@leonprou good q. It should be immutable since it is based on the immutable record stored on the blockchain for the contract. Of course, the current day will be mutable, but as described in the task, this can't be pre-calculated for clear reasons.

villanuevawill commented 6 years ago

All records in psql are just mirrors of what is in the blockchain. We're not storing anything unique on our end.

vs77bb commented 6 years ago

Hi @leonprou mind claiming this one on Gitcoin here to show you've started work? https://gitcoin.co/issue/Bounties-Network/BountiesAPI/3

Hope you both are off to a good start this week!

gitcoinbot commented 6 years ago

Work has been started on the 0.33 ETH (156.66 USD @ $474.72/ETH) funding by:

  1. @leonprou

    Please work together and coordinate delivery of the issue scope. Gitcoin doesn't know enough about everyones skillsets / free time to say who should work on what, but we trust that the community is smart and well-intentioned enough to work together. As a general rule; if you start work first, youll be at the top of the above list ^^, and should have 'dibs' as long as you follow through.

    On the above list? Please leave a comment to let the funder and the other parties involved what you're working, with respect to this issue and your plans to resolve it. If you don't leave a comment, the funder may expire your submission at their discretion.

leonprou commented 6 years ago

@villanuevawill Not sure about psql, but looking at the contract - https://github.com/Bounties-Network/StandardBounties/blob/master/contracts/StandardBounties.sol, I see a lot of methods that mutate the bounty. I'll try to catch you on slack tomorrow.

@vs77bb done 👍

villanuevawill commented 6 years ago

@leonprou - I may have misunderstood your question. By immutable, I meant the historical record for the stats will not change. There is a creation date on all of them which is grabbed from the contract. https://github.com/Bounties-Network/BountiesAPI/blob/master/bounties_api/std_bounties/models.py#L49

All the values you need will be in psql - except for acceptance date. However, we'd need to add an accepted_date field to the fulfillment model. The acceptance date can be passed through this func https://github.com/Bounties-Network/BountiesAPI/blob/master/bounties_api/std_bounties/management/commands/bounties_subscriber.py#L87 via event_timestamp which is the timestamp derived from the transaction.

In general there's complexity here, so a convo on slack may clear things up if you have q's. However, you should not need to go to the contract to get the data.

vs77bb commented 6 years ago

@leonprou @villanuevawill Poking in... you guys still working on this? Let me know if you need me to pub this out 🙂

leonprou commented 6 years ago

@vs77bb hey, for now I'm not working on this. Me and @villanuevawill have been discussing this for about a week, and have come to conclusion that some refactoring is needed before proceeding. So now I'm working on this task - https://github.com/Bounties-Network/BountiesAPI/issues/11 to store the events in the db, then I was thinking to work on some sort of event sourcing.. You're invited to join, there's enough work for all I suppose 😄 .

vs77bb commented 6 years ago

@leonprou No worries, that sounds good 👍 was just checking in from Gitcoin! Good luck with #11 in the meantime.

villanuevawill commented 6 years ago

@vs77bb actually, this should not be worked on until some of the work @leonprou does is done. Ideally would like to put this on pause for a bit...

gitcoinbot commented 6 years ago

The funding of 0.33 ETH (131.26 USD @ $397.76/ETH) attached to this issue has been killed by the bounty submitter