Skip to content

Commit cee5998

Browse files
ayushnagar123vaibhavdaren
authored andcommitted
Flask api
1 parent ba5e8a4 commit cee5998

File tree

7 files changed

+143
-45
lines changed

7 files changed

+143
-45
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ node_modules/
8686

8787
# Build Files
8888
dist/
89+
backend/venv/
90+
backend/__pycache__/
8991

9092
# Config files
9193
.prettierrc.js

Diff for: README.md

+37-17
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,61 @@
55
![Language Count](https://img.shields.io/github/languages/count/PrabhaniN/codebadge.svg)
66
[![License](https://img.shields.io/github/license/PrabhaniN/codebadge.svg)](https://github.com/PrabhaniN/Codebadge/blob/master/LICENSE)
77

8-
Well we all have been working in Open Source and committing various Pull requests and issues. Many a times it may happen that a mentor is unanle to manage all these activities. So This project is about tracking the contributor as well as its contribution by respective mentors.
8+
CodeBadge is a project which takes official GitHub API into consideration and makes a fading badges graph for each organization. This project would be organization-oriented project i.e. each organization will need to serve it on a reserved route, say /codebadge. For eg: If coala wants to integrate CodeBadge, they’ll serve this project on coala.io/codebadge. Our aim is to make CodeBadge as a standard such that people start using it as a measure in order to test their skill level/track their progress in a specific community. For eg, Competitive Coding guys test their skills by asking each other what’s their rank on HackerRank / HackerEarth! Likewise, open-source contributors should start asking, **Hey! What badge did you recently earned on CodeBadge!**
9+
10+
### Why do we need CodeBadge?
11+
- To track and incorporate contributors’ progress in the community or community’s progress as a whole. Making a one-stop platform to find each contributor’s progress rather than finding it separately for each contributor.
12+
- To show the progress by awarding some really cool badges to top contributors in order to keep them connected towards the community.
13+
- Auto-assign related issues to most active contributors using tagging to keep contributors connected.
914

10-
### Features
1115

12-
- Easy to monitor the activities of various contributors.
13-
- Visibility of top contributors in various projects.
14-
- Real time tracking of commits, PR's and other contributions.
15-
- Contributors list based on number of PR's, merged pulls and other activities.
16-
- Contribution history of each contributor.
16+
### Features
1717

18-
The other part of this project includes the “notifying moderator” since we see sometimes that there are many PRs being sent, or issues being opened by various people across the globe but there are limited numbers of maintainers merging the PRs. This way organisations usually lose their potential contributors due to following things:
18+
- GitHub Heatmaps are for each person’s profile and can be observed from visiting each contributor’s profile specifically. Whereas, our aim is to show a complete fading graph for an organization, which would hence be capable of showing each contributor’s progress as well.
19+
- There would be some pre-built badges by us as well as we offer the organization to design their own badges. This can be done by the illustrator which we are developing for this project.
20+
- Pre-defined badges could be based on some achievement levels like Baby-Steps, Not-a-Newbie, Almost-Pro, Legendary-Committer, etc which could be awarded by setting some convention like a number of merged PRs or difficulty of issues resolved by the person.
21+
- Creating/Integrating a bot with our platform which would auto-assign/auto-suggest related issues to the top-most active contributors of the community on the basis of tagging, like what their recent PRs were based upon.
22+
- Admin Dashboard creation which would show notifications/cards for whosoever earned any new badge. Community Admins should have some extra privileges to award any extra badge to an extraordinary contributor say Committer-of-the-Month, Top-Contributor, GOAT(Greatest-of-all-Times), etc manually.
23+
- The illustrator will provide the user with an interface which will help the organization to design their own badges. It has a special feature of making a sketch outline of any image which is uploaded. Once a template is uploaded by any user it will also be available to be used by other organizations. It will also provide a feature to make a shareable interface so that more than one person of an organization can work on the same badge at the same time.
1924

20-
- Their PRs are not being merged
21-
- They finds difficulty in understanding the issue
22-
- They could not reach to expectation
23-
So this will help the maintainers get notified when they see these people inactive.
2425

2526
## How does it work
2627

2728
For instance, suppose a contributor “X” has been quite active within the community by working on various PRs, opening and resolving various issues, active on chat channels but after a month “X” gets disappeared. So by using this dashboard they will have a badge interface. There will be a badge attached in front of the name of the contributor. Let the name of the badge be “Y” so this badge will have a unique color. So as the time passes like “ a day went, 1 week went, 2 weeks went, a month, etc) this badges will get keep on fading. And Every fade color will have a unique reason. For example, when a contributor made a PR, the badge appeared “Red” in color. This badge will remain in the same color as long as he/she is contributing. Assume that contributor stops contributing and has not contributed for a week so his badge will become green in color. And this will keep on notifying mainaters, Admins about their disappearing. This way the organisations will have greater eye on the contributors and can help them sustain with the community.
2829

2930
## Setting up the project
3031
To set up the project, carry out the following steps:
31-
- Clone/download the project locally
32+
33+
**Step 1:-** clone the repository
34+
35+
``` git clone https://github.com/username/Codebadge.git ```
36+
3237
- Create an [oAuth](https://github.com/settings/developers) application if you haven't already
38+
3339
- Make sure that the callback-url is set to `http://localhost:8080/#/auth`
40+
3441
- Make an `.env` file in the root folder of the project (where package.json is)
42+
3543
- Add the code given below and replace it with values from your oAuth application:
36-
`VUE_APP_CLIENT_ID=<client id>`
37-
`VUE_APP_CLIENT_SECRET=<client secret>`
38-
- Run the app using `npm start serve`
44+
```
45+
VUE_APP_CLIENT_ID=<client id>
46+
VUE_APP_CLIENT_SECRET=<client secret>
47+
```
48+
**Step 2:-** install frontend dependencies and run frontend server
49+
``` npm install && npm run serve```
50+
51+
**Step 3:-** install flask api dependencies and run api
52+
```
53+
cd backend
54+
virtualenv -p python3 venv
55+
source venv/bin/activate
56+
pip install -r requirements.txt
57+
FLASK_APP=run.py flask run
58+
```
3959

4060
## Stack used
4161

42-
This will have a dashboard, where these things can be placed. The stack used can be any but since the organisation have fixed stack so its better to stick to Nodejs, Vue, React.
62+
This will have a dashboard, where these things can be placed. The stack used can be any but since the organisation have fixed stack so its better to stick to Nodejs, Vue, Flask.
4363

4464
## Benefits to the community
4565

Diff for: backend/requirements.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Flask==1.1.1
2+
Flask-Cors==3.0.8
3+
numpy==1.16.5
4+
opencv-python==4.1.1.26
5+
requests==2.22.0
6+
Werkzeug==0.16.0

Diff for: backend/run.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from flask import Flask, render_template, jsonify,send_file,request
2+
from random import *
3+
from flask_cors import CORS
4+
import requests
5+
import numpy as np
6+
from cv2 import cv2
7+
from werkzeug.utils import secure_filename
8+
import os
9+
app = Flask(__name__,
10+
static_folder = "./dist/static",
11+
template_folder = "./dist")
12+
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
13+
14+
@app.route('/api/random')
15+
def random_number():
16+
response = {
17+
'randomNumber': randint(1, 100)
18+
}
19+
return jsonify(response)
20+
21+
@app.route('/api/upload',methods=["POST"])
22+
def upload():
23+
# file=request.files['temp']
24+
f=request.files['temp']
25+
tempname=request.form['tempname']
26+
temp_path='../templates/'
27+
name = f.filename.replace(' ','_')
28+
print(tempname)
29+
f.save(secure_filename(f.filename))
30+
31+
inputImage = cv2.imread(name)
32+
inputImageGray = cv2.cvtColor(inputImage, cv2.COLOR_BGR2GRAY)
33+
34+
edges = cv2.Canny(inputImageGray,150,200,apertureSize = 3)
35+
36+
print(edges)
37+
edges = abs(cv2.subtract(255,edges))
38+
39+
minLineLength = 30
40+
maxLineGap = 5
41+
lines = cv2.HoughLinesP(edges,cv2.HOUGH_PROBABILISTIC, np.pi/180, 30, minLineLength,maxLineGap)
42+
for x in range(0, len(lines)):
43+
for x1,y1,x2,y2 in lines[x]:
44+
pts = np.array([[x1, y1 ], [x2 , y2]], np.int32)
45+
cv2.polylines(inputImage, [pts], True, (0,255,0))
46+
47+
font = cv2.FONT_HERSHEY_SIMPLEX
48+
cv2.putText(inputImage,"Tracks Detected", (500, 250), font, 0.5, 255)
49+
50+
cv2.imwrite(temp_path+tempname+'.jpeg',edges)
51+
cv2.waitKey(0)
52+
53+
os.remove(name)
54+
55+
filename=tempname+'.jpeg'
56+
return send_file(temp_path+filename,mimetype='image/jpeg')

Diff for: backend/run.pyc

2.47 KB
Binary file not shown.

Diff for: src/router.js

+33-28
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,43 @@ import Router from 'vue-router';
33
import AuthView from './views/AuthView';
44
import HomeView from './views/HomeView';
55
import OrgView from './views/OrgView';
6+
import Upload from "./views/Upload.vue";
67
import AuthService from './services/authService';
78

89
Vue.use(Router);
910

1011
const authService = new AuthService();
1112

1213
export default new Router({
13-
routes: [
14-
{
15-
path: '',
16-
redirect: 'auth'
17-
},
18-
{
19-
path: '/auth',
20-
name: 'authView',
21-
component: AuthView
22-
},
23-
{
24-
path: '/home',
25-
name: 'homeView',
26-
component: HomeView,
27-
beforeEnter: (to, from, next) => {
28-
next(authService.isLoggedIn());
29-
}
30-
},
31-
{
32-
path: '/org/:name',
33-
name: 'orgView',
34-
component: OrgView,
35-
beforeEnter: (to, from, next) => {
36-
next(authService.isLoggedIn());
37-
}
38-
}
39-
]
40-
});
14+
routes: [{
15+
path: '',
16+
redirect: 'auth'
17+
},
18+
{
19+
path: "/upload",
20+
name: "Upload",
21+
component: Upload
22+
},
23+
{
24+
path: '/auth',
25+
name: 'authView',
26+
component: AuthView
27+
},
28+
{
29+
path: '/home',
30+
name: 'homeView',
31+
component: HomeView,
32+
beforeEnter: (to, from, next) => {
33+
next(authService.isLoggedIn());
34+
}
35+
},
36+
{
37+
path: '/org/:name',
38+
name: 'orgView',
39+
component: OrgView,
40+
beforeEnter: (to, from, next) => {
41+
next(authService.isLoggedIn());
42+
}
43+
}
44+
]
45+
});

Diff for: src/views/Upload.vue

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<div>
3+
<form action="http://localhost:5000/api/upload" method="POST" enctype="multipart/form-data">
4+
<input type="file" name="temp" id="temp">
5+
<input name="tempname" placeholder="Give your template name">
6+
<button type="submit">Upload</button>
7+
</form>
8+
</div>
9+
</template>

0 commit comments

Comments
 (0)