Skip to content

anshsrtv/leaderboard-project

Repository files navigation

Leaderboard Project

Project Swagger Documentation: https://leaderboard-project.herokuapp.com/docs/

Setup and run

  1. Create a virtual environment with Python3.7: virtualenv env -p python3.7. If you dont have python3.7 yet then you can install it with:
    1. linux(ubuntu/debian) - sudo apt install python3.7
    2. windows - Download installer from https://www.python.org/downloads/release/python-370/.
  2. Activate the virtual environment: source env/bin/activate
  3. Install all the dependencies in requirements.txt file: pip install -r requirements.txt
  4. Make a copy of .env.sample to .env and change the values of variables with original values. Click here for sample .env file.
  5. Migrate the migrations: python manage.py migrate
  6. See below for webhooks setup.
  7. Run the app: python manage.py runserver
  8. To test the APIs in your local, we can use ngrok See below for ngrok setup.
  9. Navigate to http://localhost:8000/docs/ for the swagger UI documentation in your browser.
  10. When you are done using the app, deactivate the virtual environment: deactivate

Example env file

SECRET_KEY='w0fcvcq02wh!yqiewq7)n^b7med(xop6h^@-_3j01*m0m)nz1)'
GOOD_FIRST_ISSUE_POINTS = 10
MEDIUM_ISSUE_POINTS = 20
HARD_ISSUE_POINTS = 40
OAUTH_CLIENT_ID = 'oauth_client_id'
OAUTH_CLIENT_SECRET_KEY = 'oauth_secret_key'

Ngrok Setup

  1. Install ngrok
  2. When you're done installing, you can expose your localhost by running ./ngrok http 8000 .
  3. Copy that funky *.ngrok.io URL. That's your server public URL for now.

Screenshot from 2020-06-23 22-28-50

Webhooks Setup

We recommend you go through Webhooks Docs to be able to use this project effeciently.

Screenshot from 2020-06-23 22-09-56

  1. Select any repo and head over to https://github.com/:owner/:repo/settings/hooks/new
  2. Create a webhook with payload URL (ngrok or real server) with /pull_request/ appended to it.
  3. Set the content type as application/json. No secrets for now.
  4. Select the individual event called "Pull Requests". Let the webhook be Active.
  5. Make another similar webhook with payload URL /issue/ appended to it, and select the event "issues".
  6. Also create a new Leaderboard object in the admin panel or Python shell with the, username same as the github username you are making your PRs with.

Other Instructions

This repository has been created while keeping some good coding practices and situational advantages, and so the following needs to be kept in mind while working with it.

We keep track of merged PRs and total PRs made by each user. For scoring purposes we have divided the issues into three categories. These categories are identified by adding labels to the issues.

  1. Good first issue - These are simpler issues to get you started.
  2. Medium issues - These are mildly challenging and worthwhile.
  3. Hard issues - These are definitely meant to challenge you.

We understand that each contribution is itself of great importance. So we have decided to reward all those participants who solve atleast 2 medium issues and 1 good first issue. This is taken care of by the boolean milestone_achieved.

For every issue closed, we increment points. The following needs to be kept in mind in practice.

  1. Every issue is assigned to one user only (This is important for proper points distribution and less confusion in the repository.)
  2. Every issue is solved only by the user assigned to it. The person making the PR must ensure that s/he has been assigned the issue to make sure his/her contribution is counted.
  3. Each issue shall contain only one of the labels described above.
  4. Make sure the user is registered before the PR is made for proper updation, as updation is instant.