Skip to content

Commit 03c0138

Browse files
Merge pull request #195 from hereisnaman/2020-updates
2 parents cb1d02a + 5a99d3d commit 03c0138

File tree

27 files changed

+385
-231
lines changed

27 files changed

+385
-231
lines changed

.secret.json.swp

12 KB
Binary file not shown.

:w

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/**
2+
* Created by championswimmer on 16/05/17.
3+
*/
4+
const db = require('./db')
5+
const fs = require('fs')
6+
7+
function getClaims(options) {
8+
const offset = (options.page - 1) * options.size
9+
10+
var whereClause = { status: options.status }
11+
if (options.username) {
12+
whereClause = { status: options.status, user: options.username }
13+
} else if (options.projectname) {
14+
whereClause = { status: options.status, repo: options.projectname }
15+
} else if (options.minbounty && options.maxbounty) {
16+
whereClause = { status: options.status, bounty: { $between: [options.minbounty, options.maxbounty] } }
17+
}
18+
19+
const distinctUsers = db.Claim.aggregate('user', 'DISTINCT', { plain: false, where: { status: options.status } })
20+
const distinctProjects = db.Claim.aggregate('repo', 'DISTINCT', { plain: false, where: { status: options.status } })
21+
const allClaims = db.Claim.findAndCountAll({
22+
limit: options.size,
23+
offset: offset,
24+
where: whereClause,
25+
order: [['updatedAt', 'DESC']]
26+
})
27+
28+
return Promise.all([distinctUsers, allClaims, distinctProjects])
29+
}
30+
31+
function getClaimById(claimId) {
32+
return db.Claim.findById(claimId)
33+
}
34+
35+
function delClaim(claimId) {
36+
if (isNaN(+claimId)) {
37+
return res.send('ClaimId must be a number')
38+
}
39+
return db.Claim.destroy({
40+
where: {
41+
id: claimId
42+
}
43+
})
44+
}
45+
46+
function updateClaim(claimId, { status, reason, bounty }) {
47+
const claim = {
48+
action: 'update',
49+
claimId,
50+
status,
51+
bounty
52+
}
53+
fs.writeFile(__dirname + '/../audit/' + new Date().toISOString() + '.json', JSON.stringify(claim), () => {})
54+
55+
return db.Claim.update(
56+
{
57+
status: status,
58+
reason: reason,
59+
bounty: bounty
60+
},
61+
{
62+
where: {
63+
id: claimId
64+
},
65+
returning: true
66+
}
67+
)
68+
}
69+
70+
function createClaim(user, issueUrl, pullUrl, bounty, status) {
71+
const claim = {
72+
action: 'create',
73+
user,
74+
issueUrl,
75+
pullUrl,
76+
bounty,
77+
status
78+
}
79+
fs.writeFile(__dirname + '/../audit/' + new Date().toISOString() + '.json', JSON.stringify(claim), () => {})
80+
81+
return db.Claim.create({
82+
user,
83+
issueUrl,
84+
pullUrl,
85+
repo: pullUrl.split('github.com/')[1].split('/')[1],
86+
bounty: bounty,
87+
status: status
88+
})
89+
}
90+
91+
function getLeaderboard(options = {}) {
92+
options.size = parseInt(options.size || 0)
93+
const offset = (options.page - 1) * options.size
94+
95+
const userCount = db.Claim.aggregate('user', 'count', { distinct: true })
96+
97+
const results = db.Database.query(`SELECT "user",
98+
SUM(CASE WHEN "claim"."status" = 'accepted' THEN "bounty" ELSE 0 END) as "bounty",
99+
COUNT("bounty") as "pulls"
100+
FROM "claims" AS "claim"
101+
GROUP BY "user"
102+
ORDER BY SUM(CASE WHEN "claim"."status" = 'accepted' THEN "bounty" ELSE 0 END) DESC, COUNT("bounty") DESC
103+
LIMIT ${options.size} OFFSET ${offset}`)
104+
105+
return Promise.all([userCount, results])
106+
}
107+
108+
function getCounts() {
109+
const participants = db.Claim.aggregate('user', 'count', { distinct: true })
110+
const claims = db.Claim.aggregate('*', 'count')
111+
var accepted = db.Claim.aggregate('bounty', 'sum', {
112+
where: {
113+
status: 'accepted'
114+
}
115+
})
116+
var totalclaimed = db.Claim.aggregate('bounty', 'sum')
117+
118+
var filterNaN = data => data || 0
119+
120+
var counts = Promise.all([participants, claims, accepted, totalclaimed]).then(values => values.map(filterNaN))
121+
122+
return counts
123+
}
124+
125+
module.exports = {
126+
getClaims,
127+
delClaim,
128+
createClaim,
129+
getLeaderboard,
130+
getClaimById,
131+
updateClaim,
132+
getCounts
133+
}

public_static/lib/semantic/semantic.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,14 +764,14 @@ body .ui.inverted::-webkit-scrollbar-thumb:hover {
764764
font-family: 'Cabin';
765765
font-style: normal;
766766
font-weight: 400;
767-
src: local('Cabin'), local('Cabin-Regular'), url(https://fonts.gstatic.com/s/cabin/v13/u-4x0qWljRw-Pd8w__g.ttf) format('truetype');
767+
src: local('Cabin'), local('Cabin-Regular'), url(https://fonts.gstatic.com/s/cabin/v14/u-4x0qWljRw-Pd8w__g.ttf) format('truetype');
768768
}
769769

770770
@font-face {
771771
font-family: 'Quicksand';
772772
font-style: normal;
773773
font-weight: 400;
774-
src: local('Quicksand Regular'), local('Quicksand-Regular'), url(https://fonts.gstatic.com/s/quicksand/v9/6xKtdSZaM9iE8KbpRA_hK1QI.ttf) format('truetype');
774+
src: url(https://fonts.gstatic.com/s/quicksand/v20/6xK-dSZaM9iE8KbpRA_LJ3z8mH9BOJvgkP8o58a-xw.ttf) format('truetype');
775775
}
776776
/*!
777777
* # Semantic UI 2.4.2 - Button

public_static/lib/semantic/semantic.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public_static/lib/semantic/themes/basic/assets/fonts/icons.eot

100755100644
File mode changed.

public_static/lib/semantic/themes/basic/assets/fonts/icons.svg

100755100644
File mode changed.

public_static/lib/semantic/themes/basic/assets/fonts/icons.ttf

100755100644
File mode changed.

public_static/lib/semantic/themes/basic/assets/fonts/icons.woff

100755100644
File mode changed.

public_static/lib/semantic/themes/github/assets/fonts/octicons-local.ttf

100755100644
File mode changed.

public_static/lib/semantic/themes/github/assets/fonts/octicons.svg

100755100644
File mode changed.

0 commit comments

Comments
 (0)