algoristas / api

Algorists dashboard API
4 stars 1 forks source link

Issues#4: GET /v1/users/:userId/problems/:prolemId (for codeforces) #15

Closed rendon closed 6 years ago

rendon commented 6 years ago

Retrieve problem details from Codeforces

In this change I am implementing the following endpoint:

GET /v1/users/:userId/problems/:prolemId

Where userId and problemId are internal IDs, created by our system when users registered in our platform and problems were added.

While implementing this feature I realized that there are many other features that should have been implemented before this one, like user management, creation of problems, etc.

Examples (see problems.json file for problem IDs):

$ curl localhost:8080/v1/users/rendon/problems/1 | python -m json.tool
{
    "data": {
        "ExternalID": "580C",
        "HasSolved": true,
        "HasTried": true,
        "ID": 1,
        "OwnerID": 3,
        "Source": "http://codeforces.com/problemset/problem/580/C",
        "Title": "Kefa and Park"
    },
    "statusCode": 200
}
$ curl localhost:8080/v1/users/dventura11/problems/1 | python -m json.tool
{
    "data": {
        "ExternalID": "580C",
        "HasSolved": false,
        "HasTried": false,
        "ID": 1,
        "OwnerID": 3,
        "Source": "http://codeforces.com/problemset/problem/580/C",
        "Title": "Kefa and Park"
    },
    "statusCode": 200
}
$ curl localhost:8080/v1/users/rendon/problems/4 | python -m json.tool
{
    "data": {
        "ExternalID": "779D",
        "HasSolved": true,
        "HasTried": true,
        "ID": 4,
        "OwnerID": 3,
        "Source": "http://codeforces.com/contest/779/problem/D",
        "Title": "String Game"
    },
    "statusCode": 200
}
$ curl localhost:8080/v1/users/xiddw/problems/4 | python -m json.tool
{
    "data": {
        "ExternalID": "779D",
        "HasSolved": true,     <---- This is actually wrong (at the time of this writing), it's been fixed
        "HasTried": false,
        "ID": 4,
        "OwnerID": 3,
        "Source": "http://codeforces.com/contest/779/problem/D",
        "Title": "String Game"
    },
    "statusCode": 200
}
rendon commented 6 years ago

Note for myself: squash commits