Code Monkey home page Code Monkey logo

api's People

Contributors

dependabot[bot] avatar imsaptarshi avatar mohamed040406 avatar shubhaankar-sharma avatar syltea avatar takos22 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

api's Issues

Challenge Languages

A part of our new challenge system is that participants will be able to select what language they want to complete our challenges in, depending on the challenge.

For this we have created the ChallengeLanguage model.
https://github.com/Tech-With-Tim/models/blob/main/challenges/language.py#L7-L27


Endpoints

All endpoints require ManageWeeklyChallengeLanguages permission.

GET @ /challenges/languages

Fetches all all languages rows.
Alphabetically sorted.


POST @ /challenges/languages

Creates a new ChallengeLanguage row.


GET @ /challenges/languages/{id}

Fetches this specific language and the active challenges that are using it.
Challenges are a minimized version (id, title, description, released_at, deleted, slug) and should be ordered by released_at descending.

PATCH @ /challenges/languages/{id}

Updates only the provided portion of the object.

DELETE @ /challenges/languages/{id}

If the language is used in any challenge, do not delete the language.
This would delete any submissions using it.

If the language has never been used you can delete it.
Make sure to also remove it from any languages: Array[bigint] columns on the Challenge model.

[BUG] Role model updates

The UpdateRoleBody and NewRoleBody have some issues and need some updates, here are the needed updates:

  1. The UpdateRoleBody.name has a max_length of 64 instead of the 32 in NewRoleBody.name.

    name: str = Field("", min_length=4, max_length=64)

  2. The NewRoleBody.color and UpdateRoleBody.color could use a pydantic.Color field instead of the current int field.

    color: Optional[int] = Field(None, le=0xFFFFFF, ge=0)
    color: Optional[int] = Field(None, le=0xFFFFFF, ge=0)

Challenges

Endpoints

GET @ /challenges

Fetches all challenges which are not deleted and released. Deleted challenges will have deleted set to true, and released challenges will have a date in released_at. Only users with ViewUpcomingWeeklyChallenge permission should be able to see unreleased challenges.

If the user can see deleted challenges, deleted should be added in the challenge response

Challenge Object should look something like this:

{
  "id": "string",
  "title": "string",
  "description": "string",
  "author_id": "string",
  "language_ids": ["string"],
  "released_at": "date/null",
  "slug": "string"
}

if the user has any WeeklyChallenges permission, they should be able to see deleted challenges.

This endpoint needs pagination


POST @ /challenges

Creates a new Challenge. If the challenge is created successfully should return 201 Created with the challenge data.

Needs CreateWeeklyChallenge permission

Body

{
  "title": "string",
  "description": "string",
  "example_in": ["string"],
  "example_out": ["string"],
  "language_ids": ["string"]
}

GET @ /challenges/{id/slug}

Fetch said challenge by id or slug.

Challenge object should something similar to this:

{
  "id": "string",
  "title": "string",
  "description": "string",
  "author_id": "string",
  "author": {
    "id": "string",
    "name": "string",
    "avatar": "string",
    "discriminator": "string"
  },
  "example_in": ["string"],
  "example_out": ["string"],
  "languages": [
    {
      "id": "string",
      "name": "string",
      "download_url": "string"
    }
  ],
  "released_at": "date/null",
  "slug": "string",
  "submissions": "integer"
}

The checks done on GET @ /challenges should be done here too (deleted and unreleased)


PATCH @ /challenges/{id}

Updates said challenge. Should return 200 OK with the new challenge data.

Needs EditWeeklyChallenge permission

Body

{
  "title": "string",
  "description": "string",
  "example_in": ["string"],
  "example_out": ["string"],
  "language_ids": ["string"]
}

All fields should be optional


PUT @ /challenges/{id}/release

Releases/Unreleases said challenge. Should return 204 No Content if executed successfully.

Needs EditWeeklyChallenge permission


DELETE @ /challenges/{id}

Update said challenge and set deleted to true. If executed successfully 204 No Content should be returned.

Needs DeleteWeeklyChallenge permission

Reload dev server on file edits

Is your feature request related to a problem? Please describe.

I have to restart the app every time I make a change which is very time consuming. Doing this with hypercorn's default config.use_reloader and watchdog don't work that is why I added this here so if someone would know how to do this.

Describe the solution you'd like

The app should reload when I make a change in any of the directories. Similar to what happens in Django, Flask and the default way to run quart.

Describe alternatives you've considered

Using quarts default runner using app.run or adding the QUART_APP and other quart variable to the .env variables.

Additional context

I know this will take time to implement as the above solutions may give errors too.

User username and discrim are unique

Describe the bug

The User model username and discrim are unique but they shouldn't be. So, takos#0001 and takos#6969 would conflict and even worse, Biz#6969 and takos#6969 would also conflict.

To Reproduce

Create 2 users with the same username or discrim.

Expected behavior

One of the users isn't created because it conflicts with the other user.

Additional context

None

Challenge Submissions

Endpoints

GET @ /challenges/{id}/submissions

Gets a list of submitted solutions for said challenge.

Only available if the challenge has ended (now() >= released_at + interval '7' days) or if the user has ManageSubmissions permission.

Submission Object should be something like this:

{
  "id": "string",
  "challenge_id": "string",
  "author_id": "string",
  "author": {
    "id": "string",
    "name": "string",
    "avatar": "string",
    "discriminator": "string"
  },
  "language": {
    "id": "string",
    "name": "string"
  },
  "code": "string"
}

Pagination Required


GET @ /challenges/{id}/submissions/{user_id/submission_id}

GET @ /challenges/{id}/submissions/@me should also be available

Gets a submission for said user by their user id or submission id.
Submission Object should be the same as the one in GET @ /challenges/{id}/submissions

One of the following conditions should be true for this endpoint to be available:

  • If the user is the author of the submission
  • If the challenge has ended
  • If the user has ManageSubmissions permission

POST @ /challenges/{id}/submissions

Creates a new submission for said challenge. Returns 201 Created on success and return id in Location header.

Body

{
  "language": "string",
  "code": "string"
}

DELETE @ /challenges/{challenge_id}/submissions/{id}

Deletes said submission from said challenge. Returns 204 No Content on success.

Needs ManageSubmissions Permission

Test

This is merely a test.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.