Skip to content

Commit a3e16dd

Browse files
committed
Added Badges and Contributor Tracking
Improved contributor tracking Added Predefined Badges Added Special Badges Added a /badge route and tooltips
1 parent aaae9bc commit a3e16dd

27 files changed

+804
-191
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ backend/venv/
9090
backend/__pycache__/
9191

9292
# Config files
93-
.prettierrc.js
93+
.prettierrc.js
2.41 KB
Loading
28.5 KB
Loading
1.16 KB
Loading
24.6 KB
Loading
1.95 KB
Loading

public/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<meta charset="utf-8" />
66
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=yes" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
88
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
99
<title>CodeBadge</title>
1010
<link
@@ -19,6 +19,9 @@
1919
href="https://fonts.googleapis.com/css?family=Roboto+Condensed&display=swap"
2020
rel="stylesheet"
2121
/>
22+
<link
23+
href="https://fonts.googleapis.com/css?family=Raleway&display=swap"
24+
rel="stylesheet">
2225
<link
2326
href="https://fonts.googleapis.com/css?family=Material+Icons"
2427
rel="stylesheet"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"name": "Baby Steps",
4+
"min_commits": 0,
5+
"max_commits": 10000,
6+
"badge": "babysteps.png",
7+
"tooltip": "10000 commits or less",
8+
"information": {
9+
"title": "Baby Steps",
10+
"description": "Assigned to all beginners."
11+
}
12+
}
13+
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import rawdata from "./badges";
2+
3+
const json = JSON.parse(JSON.stringify(rawdata));
4+
const badgeURLPrefix = "/assets/badges/predefined/";
5+
6+
export default class PredefinedBadges {
7+
getBadge(commits) {
8+
let url = "";
9+
let tooltip = "";
10+
json.forEach(function(badge) {
11+
if (commits >= badge.min_commits && commits <= badge.max_commits) {
12+
url = badgeURLPrefix + badge.badge;
13+
tooltip = badge.tooltip;
14+
}
15+
});
16+
return {url: url, tooltip: tooltip};
17+
}
18+
19+
getBadgeFromName(name) {
20+
let data = {};
21+
json.forEach(function(badge) {
22+
if(badge.name === name)
23+
{
24+
data = badge;
25+
}
26+
});
27+
return data;
28+
}
29+
30+
getBadgeURLPrefix()
31+
{
32+
return badgeURLPrefix;
33+
}
34+
35+
getAllBadgeIDs()
36+
{
37+
let keys = [];
38+
for(let i in json)
39+
keys.push(json[i].name);
40+
return keys;
41+
}
42+
}

src/assets/badges/special/badges.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"topContributor": {
3+
"badge": "topcommits.png",
4+
"tooltip": "Awarded to the top contributor of your organization!",
5+
"information": {
6+
"title": "Top Contributor of All Time",
7+
"description": "Assigned to the person who has the highest commits in your organization!"
8+
}
9+
},
10+
"topWeekContributor": {
11+
"badge": "topweekcommits.png",
12+
"tooltip": "Awarded to the one with with highest commits last week!",
13+
"information": {
14+
"title": "Top Contributor this Week",
15+
"description": "Assigned to the person who had the highest commits last week in your organization!"
16+
}
17+
},
18+
"topMonthContributor": {
19+
"badge": "topmonthcommits.png",
20+
"tooltip": "Awarded to the one with with highest commits this month!",
21+
"information": {
22+
"title": "Top Contributor this Month",
23+
"description": "Assigned to the person who has the highest commits this month in your organization!"
24+
}
25+
},
26+
"topYearContributor": {
27+
"badge": "topyearcommits.png",
28+
"tooltip": "Awarded to the one with with highest commits this year!",
29+
"information": {
30+
"title": "Top Contributor this Year",
31+
"description": "Assigned to the person who has the highest commits this year in your organization!"
32+
}
33+
}
34+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import store from "../../../store";
2+
import rawdata from "./badges";
3+
4+
const json = JSON.parse(JSON.stringify(rawdata));
5+
const badgeURLPrefix = "/assets/badges/special/";
6+
7+
export default class SpecialBadges {
8+
getBadges(name, orgName) {
9+
let badges = [];
10+
11+
const topCommits = store.getters.getTopCommits(orgName);
12+
const topWeekCommits = store.getters.getTopWeekCommits(orgName);
13+
const topMonthCommits = store.getters.getTopMonthCommits(orgName);
14+
const topYearCommits = store.getters.getTopYearCommits(orgName);
15+
16+
//Make sure to sort in descending order of priority of display
17+
18+
if (topCommits[0].name === name) {
19+
badges.push({
20+
url: badgeURLPrefix + json["topContributor"].badge,
21+
tooltip: json["topContributor"].tooltip
22+
});
23+
}
24+
25+
if (topWeekCommits[0].name === name) {
26+
if (topWeekCommits[0].weeks[topWeekCommits[0].weeks.length - 1].c > 0) {
27+
badges.push({
28+
url: badgeURLPrefix + json["topWeekContributor"].badge,
29+
tooltip: json["topWeekContributor"].tooltip
30+
});
31+
}
32+
}
33+
34+
if (topMonthCommits[0].name === name) {
35+
let actuallyHasCommited = false;
36+
for (let week in topMonthCommits[0].weeks) {
37+
if (week.c > 0) {
38+
actuallyHasCommited = true;
39+
break;
40+
}
41+
}
42+
if (topMonthCommits[0].weeks.length < 4) actuallyHasCommited = false;
43+
if (actuallyHasCommited)
44+
badges.push({
45+
url: badgeURLPrefix + json["topMonthContributor"].badge,
46+
tooltip: json["topMonthContributor"].tooltip
47+
});
48+
}
49+
50+
if (topYearCommits[0].name === name) {
51+
let actuallyHasCommited = false;
52+
for (let week in topYearCommits[0].weeks) {
53+
if (week.c > 0) {
54+
actuallyHasCommited = true;
55+
break;
56+
}
57+
}
58+
if (topYearCommits[0].weeks.length < 52) actuallyHasCommited = false;
59+
if (actuallyHasCommited)
60+
badges.push({
61+
url: badgeURLPrefix + json["topYearContributor"].badge,
62+
tooltip: json["topYearContributor"].tooltip
63+
});
64+
}
65+
66+
return badges;
67+
}
68+
69+
getBadgeFromName(name) {
70+
return json[name];
71+
}
72+
73+
getBadgePrefixURL() {
74+
return badgeURLPrefix;
75+
}
76+
77+
getAllBadgeIDs() {
78+
let keys = [];
79+
for(let key in json)
80+
keys.push(key);
81+
return keys;
82+
}
83+
}

src/components/auth/Login.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export default {
3535
const code = window.location.href.match(/\?code=(.*)/);
3636
if (code) {
3737
this.isLoading = true;
38-
console.log(this.isLoading);
3938
axios({
4039
method: `post`,
4140
url: `${AxiosHelper.gatekeeperUrl}?client_id=${
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<template>
2+
<div>
3+
<v-card outline class="mx-auto org">
4+
<v-card-title>
5+
<v-avatar size="60">
6+
<v-img class="elevation-6" :src="avatar" />
7+
</v-avatar>
8+
<span class="title">{{ title }}</span>
9+
</v-card-title>
10+
<div class="description">
11+
{{ description }}
12+
</div>
13+
</v-card>
14+
</div>
15+
</template>
16+
17+
<script>
18+
import PredefinedBadges from "../../assets/badges/predefined/predefinedBadges";
19+
import SpecialBadges from "../../assets/badges/special/specialBadges";
20+
21+
let predefinedBadges = new PredefinedBadges();
22+
let specialBadges = new SpecialBadges();
23+
export default {
24+
name: "BadgeListItem",
25+
props: {
26+
name: {
27+
type: String
28+
},
29+
isSpecial: {
30+
type: Boolean
31+
}
32+
},
33+
data() {
34+
return {
35+
badgeData: {}
36+
};
37+
},
38+
computed: {
39+
avatar() {
40+
let prefixURL = predefinedBadges.getBadgeURLPrefix();
41+
if(this.isSpecial)
42+
prefixURL = specialBadges.getBadgePrefixURL();
43+
return prefixURL + this.badgeData.badge;
44+
},
45+
title() {
46+
return this.badgeData['information'].title;
47+
},
48+
description() {
49+
return this.badgeData['information'].description;
50+
}
51+
},
52+
created() {
53+
if(this.isSpecial)
54+
this.badgeData = specialBadges.getBadgeFromName(this.name);
55+
else
56+
this.badgeData = predefinedBadges.getBadgeFromName(this.name);
57+
}
58+
};
59+
</script>
60+
61+
<style>
62+
.description {
63+
margin-left: 100px;
64+
padding-bottom: 15px;
65+
font-size: 15px;
66+
}
67+
</style>

src/components/general/Toolbar.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<v-toolbar color="white" app>
3-
<v-toolbar-title style="font-size: 30px; font-family: Raleway; padding-right: 20px">
3+
<v-toolbar-title class="toolbar">
44
<span>Codebadge</span>
55
</v-toolbar-title>
66
<v-spacer />
@@ -15,6 +15,7 @@
1515
<script>
1616
import AxiosHelper from "../../config/AxiosHelper";
1717
import AuthService from "../../services/authService";
18+
import axios from 'axios';
1819
1920
const authService = new AuthService();
2021
@@ -39,6 +40,12 @@ export default {
3940
</script>
4041

4142
<style lang="scss" >
43+
.toolbar {
44+
font-size: 30px;
45+
font-family: 'Raleway';
46+
padding-right: 20px
47+
}
48+
4249
.toolbar-button {
4350
padding-top: 5px;
4451
}

src/components/home/OrgList.vue

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,56 @@
11
<template>
22
<div>
33
<v-card flat>
4-
<v-list>
5-
<v-list-tile
6-
v-for="org in orgsData"
7-
:key="org.name"
8-
@click="viewOrg(org.name)"
9-
avatar
10-
ripple
11-
>
4+
<v-card
5+
v-for="org in orgsData"
6+
:key="org.name"
7+
@click="viewOrg(org.name)"
8+
hover
9+
flat
10+
ripple
11+
class="mx-auto org"
12+
>
13+
<v-card-title>
1214
<v-list-tile-avatar>
13-
<img :src="org.avatar">
15+
<v-img class="elevation-6" :src="org.avatar" />
1416
</v-list-tile-avatar>
15-
16-
<v-list-tile-content>
17-
<v-list-tile-title v-html="org.name"></v-list-tile-title>
18-
</v-list-tile-content>
19-
</v-list-tile>
20-
</v-list>
17+
<span class="title font-weight-light">{{ org.name }}</span>
18+
</v-card-title>
19+
<OrgContributors :orgName="org.name" />
20+
</v-card>
2121
</v-card>
2222
</div>
2323
</template>
2424

2525
<script>
26+
import OrgContributors from "../org/OrgContributors";
27+
2628
export default {
27-
name: 'OrgList',
29+
name: "OrgList",
30+
components: {
31+
OrgContributors
32+
},
33+
data() {
34+
return {
35+
contributors: []
36+
};
37+
},
2838
computed: {
2939
orgsData() {
3040
return this.$store.getters.orgsData;
3141
}
3242
},
3343
methods: {
3444
viewOrg(name) {
35-
this.$router.push({ name: 'orgView', params: { name: name } });
45+
if(this.$store.state.isOrgLoaded[name])
46+
this.$router.push({ name: "orgView", params: { name: name } });
3647
}
3748
}
3849
};
3950
</script>
4051

4152
<style lang="scss" scoped>
42-
</style>
53+
.org {
54+
margin-bottom: 8px;
55+
}
56+
</style>

src/components/home/UserDetails.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
<div>
33
<v-card flat ripple>
44
<v-layout justify-center row>
5-
<v-flex>
65
<v-avatar size="80">
76
<img :src="userData.dp">
87
</v-avatar>
9-
</v-flex>
108
<v-flex>
119
<div class="username ml-3">{{userData.username}}</div>
1210
<div class="github-name ml-3">{{userData.githubName}}</div>

0 commit comments

Comments
 (0)