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

Expose Grant information via API #6633

Merged
merged 3 commits into from
Jun 5, 2020

Conversation

sebastiantf
Copy link
Contributor

@sebastiantf sebastiantf commented May 12, 2020

Description

Adds a new endpoint: /api/v0.1/grants/report

URL Query parameters:

  • eth_address: Ethereum address
  • from_timestamp: Timestamp to filter contributions received by Grantee. Example: 2019-01-15T01:24:15Z
  • to_timestamp: Similar to from_timestamp

Example:

Request:

GET /api/v0.1/grants/report/?eth_address=0xCC4b3DE30576E161C8632786560Fa7DD3Fb33f77&from_timestamp=2020-05-01T01:24:15Z&to_timestamp=2020-05-30T01:24:15Z

Response:
{
    "grantee": [
        {
            "grant_name": "Another grant for me",
            "transactions": [
                {
                    "asset": "DAI",
                    "timestamp": "2020-05-06T05:24:42Z",
                    "amount": "47250000000000000000",
                    "clr_round": null,
                    "usd_value": 47.25
                }
            ],
            "clr_payouts": [
                {
                    "amount": 250.0,
                    "asset": "DAI",
                    "usd_value": 250.0,
                    "timestamp": "2020-05-15T06:12:16Z",
                    "round": 4
                },
                {
                    "amount": 400.0,
                    "asset": "DAI",
                    "usd_value": 400.0,
                    "timestamp": "2020-05-15T06:12:23Z",
                    "round": 5
                }
            ]
        }
    ],
    "donor": [
        {
            "grant_name": "Go Fund My Test Grant",
            "asset": "DAI",
            "timestamp": "2020-05-12T01:24:15Z",
            "grant_amount": "4750000000000000000",
            "gitcoin_maintenance_amount": "250000000000000000",
            "grant_usd_value": 4.75,
            "gitcoin_usd_value": 0.25
        }
    ]
}
Refers/Fixes

Fixes #6493

Testing

grants_report_api_final

@codecov
Copy link

codecov bot commented May 12, 2020

Codecov Report

Merging #6633 into master will decrease coverage by 0.51%.
The diff coverage is 42.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6633      +/-   ##
==========================================
- Coverage   27.22%   26.70%   -0.52%     
==========================================
  Files         288      294       +6     
  Lines       26865    28094    +1229     
  Branches     3965     4131     +166     
==========================================
+ Hits         7313     7503     +190     
- Misses      19280    20325    +1045     
+ Partials      272      266       -6     
Impacted Files Coverage Δ
app/grants/models.py 48.99% <16.66%> (-0.27%) ⬇️
app/grants/router.py 33.33% <18.42%> (-23.34%) ⬇️
app/grants/utils.py 21.05% <23.52%> (+2.00%) ⬆️
app/grants/serializers.py 75.90% <68.75%> (-24.10%) ⬇️
app/dashboard/sync/helpers.py 27.27% <0.00%> (-39.40%) ⬇️
app/townsquare/utils.py 15.78% <0.00%> (-10.88%) ⬇️
app/economy/models.py 53.48% <0.00%> (-5.95%) ⬇️
app/kudos/admin.py 56.04% <0.00%> (-4.20%) ⬇️
app/dashboard/utils.py 41.32% <0.00%> (-2.86%) ⬇️
app/dashboard/tasks.py 36.48% <0.00%> (-2.41%) ⬇️
... and 49 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab1cebf...7871c92. Read the comment docs.

@Jack-Works
Copy link

There're still some information missing in the API IMO 🤔

@thelostone-mc thelostone-mc requested a review from owocki May 13, 2020 05:52
@thelostone-mc
Copy link
Member

thelostone-mc commented May 13, 2020

@LefterisJP + @owocki soft review needed !

@Jack-Works If you could list out what's missing / even better -> raise a PR against
@sebastiantf branch. It would be pretty dope ^_^

@sebastiantf
Copy link
Contributor Author

@Jack-Works Have you checked out the endpoint at https://gitcoin.co/api/v0.1/grants/. It lists all the data related to all the grants and you could query a specific grant with it's pk.

Please do check that endpoint to see if it helps and feel free to specifically mention any other data that you think you need and the structure of the response as done in the original comment for this issue #6493

Also feel free to join the discussion at the issue page #6493

@Jack-Works
Copy link

Oh @sebastiantf yes it cover most of our cases (#6493 (comment) )

@octavioamu
Copy link
Contributor

left a comment #6650 (comment)

@sebastiantf
Copy link
Contributor Author

@octavioamu How do you mean to extend grants.json?

@owocki
Copy link
Contributor

owocki commented May 13, 2020 via email

@sebastiantf
Copy link
Contributor Author

https://gitcoin.co/grants/grants.json

I am aware of that endpoint. But it only contains the admin address for each grant, right? Wouldn't a better REST API endpoint be better?

@sebastiantf
Copy link
Contributor Author

@Jack-Works This hasn't been merged yet. So it's not live yet.

@Tedko
Copy link

Tedko commented Jun 1, 2020

@Jack-Works This hasn't been merged yet. So it's not live yet.

Any idea or roadmap of merging this? We’re trying to integrate this into Maskbook to maximize the UX and make more people to donate easily

@owocki
Copy link
Contributor

owocki commented Jun 1, 2020

hey @gitcoinco/engineers i've got a request from an external collaborator to get this in to be live before round 6. to get ahead of that could we get it in review? given that its greenfield functionality, im hopeful that its not too much chance of regression.

We’re trying to finish the integrate and publish it to chrome store soon. Sometimes chrome store etc will spend several days to review. Try to catch up to the next grant on Jun/15 so we can bring more people on board to donate to grants

From Suji on telegram.. ^^

Copy link
Contributor

@danlipert danlipert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice and clean!

Copy link
Contributor

@PixelantDesign PixelantDesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer to engineering on this one!

@thelostone-mc thelostone-mc merged commit 65edebb into gitcoinco:master Jun 5, 2020
@sebastiantf
Copy link
Contributor Author

Thanks for the merge!

@owocki
Copy link
Contributor

owocki commented Jun 8, 2020

try now, the API is live

@Jack-Works
Copy link

Thanks

@owocki
Copy link
Contributor

owocki commented Jun 9, 2020

@sebastiantf did you performance test your PR? looks like the second issue is timing out.

@sebastiantf
Copy link
Contributor Author

@owocki @Jack-Works It seems the current output from the /grants/report/ endpoint contains duplicate entries, which is supposedly causing a performance issue at the endpoint, ultimately leading to a 502

https://gitcoin.co/api/v0.1/grants/report/?eth_address=0x89d1FeC16BA1c8aEbC7866263eb4Ca2D8bD8EeC4

The above request returns fine without a 502, but duplicate entries can be found.

I have a PR up at #6830 that should fix this.

@Tedko
Copy link

Tedko commented Jun 11, 2020 via email

@yisiliu
Copy link

yisiliu commented Jun 22, 2020

https://gitcoin.co/api/v0.1/grants/report/?eth_address=0x89d1FeC16BA1c8aEbC7866263eb4Ca2D8bD8EeC4

The above request returns fine without a 502, but duplicate entries can be found.

I have a PR up at #6830 that should fix this.

It's still returning 502. Can you take a look why?

@sebastiantf
Copy link
Contributor Author

@yisiliu #6830 isn't merged yet

@yisiliu
Copy link

yisiliu commented Jun 22, 2020

https://gitcoin.co/api/v0.1/grants/report/?eth_address=0x89d1FeC16BA1c8aEbC7866263eb4Ca2D8bD8EeC4
The above request returns fine without a 502, but duplicate entries can be found.

It didn't return fine without a 502, which #6830 won't help at all.

@yisiliu
Copy link

yisiliu commented Jun 28, 2020

Got it. Thanks!

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

Successfully merging this pull request may close these issues.

Expose Grant information via API endpoints for Rotki and other api consumers
9 participants