algoristas / api

Algorists dashboard API
4 stars 1 forks source link

Design API for: User X has solved Y problem #3

Open rendon opened 6 years ago

rendon commented 6 years ago

We have to come up with an URI and the response format.

Some ideas for the URI:

/problems/{id}/: For a given problem, return the list of users that have solved this particular proble

{
    "id": "123",
    "source": "http://codeforces.com/problemset/problem/580/C",
    "resolvers": ["user1", "user2", "user3"]
}

/users/{user_id}/solutions/{solution_id}: For a given user return the details of his solution, or indicate he has not solved the problem.

{
    "id": "1234",
    "source": "http://codeforces.com/problemset/problem/580/C",
    "status": "AC|WA|NA",
    "lang": "C++"
}
hopkins0 commented 6 years ago

I think we should add this end-point so we can know all the submitions of a problem.

/users/{user_id}/problem/{problem_id}/submitions/: For a given user return the Id's of all his submitions to a given problem.

{
    "problem_id": "1234",
    "source": "http://codeforces.com/problemset/problem/580/C",
    "submitions":  ["submitions_id_1", "submitions_id_2", "submitions_id_3"]
}

Also, we can add a filter to the request so we can get all the submitions for a problem with a particular status.

/users/{user_id}/problem/{problem_id}/submitions/status/{status}: For a given user return the Id's of all the submitions with a particular status for a given problem.

{
    "problem_id": "1234",
    "source": "http://codeforces.com/problemset/problem/580/C",
    "submitions":  ["submitions_id_1", "submitions_id_2", "submitions_id_3"]
}
rendon commented 6 years ago

@hopkins0 do we need ALL the submissions? Or do we only need to know if the user has solved the problem?

Also, the /usrs/{user_id}/problems/{problem_id} is used to indicate that a given user owns a problem, but in our platform the user does not own the problem, he/she just solves problems. Just something we should keep in mind.

rendon commented 6 years ago

@hopkins0 Actually, yes, a user can own problems, at least it could in the future.

https://imgur.com/GYHJ5SY

  1. A User solves zero or more problem
  2. A User owns zero or more problems

Therefore I propose this:

URI: /users/{user_id}/problems/{problem_id} Reponse:

{
    "problem_id": 123,
    "owner_id": 456,
    "title": "Kefa and Park",
    "source": "http://codeforces.com/problemset/problem/580/C",
    "has_solved": "NO",
    "has_tried": "YES"
}

This solves the original problem: Determine if user X has solved problem Y.

Later on when retrieving data for the dashboard we'll need another operation to retrieve this information for a set of problems (o even for a set of users), instead of making one call for every problem in the set, but this will be addressed in a future story.

Gansito144 commented 6 years ago

I would go with this last proposal /users/{user_id}/problems/{problem_id}, but also I like the original endpoint : /problems/{id}/ but I think it could contain more information about the users who tried it also.

{
    "id": "123",
    "source": "http://codeforces.com/problemset/problem/580/C",
    "tags": ["dp", "trees"]
    "users_list": [
        {
          "user_id": "user1",
          "status": "AC|WA|NA"
        },
        {
          "user_id": "user1",
          "status": "AC|WA|NA"
        }
    ]
}
rendon commented 6 years ago

We can have both, the one I propose is to solve this issue's problem. /problems/{problem_id} could return general information about a problem, not tied to any particular user.