diff --git a/.secret.json.swp b/.secret.json.swp deleted file mode 100644 index 516408e..0000000 Binary files a/.secret.json.swp and /dev/null differ diff --git a/:w b/:w deleted file mode 100644 index fde4c0a..0000000 --- a/:w +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Created by championswimmer on 16/05/17. - */ -const db = require('./db') -const fs = require('fs') - -function getClaims(options) { - const offset = (options.page - 1) * options.size - - var whereClause = { status: options.status } - if (options.username) { - whereClause = { status: options.status, user: options.username } - } else if (options.projectname) { - whereClause = { status: options.status, repo: options.projectname } - } else if (options.minbounty && options.maxbounty) { - whereClause = { status: options.status, bounty: { $between: [options.minbounty, options.maxbounty] } } - } - - const distinctUsers = db.Claim.aggregate('user', 'DISTINCT', { plain: false, where: { status: options.status } }) - const distinctProjects = db.Claim.aggregate('repo', 'DISTINCT', { plain: false, where: { status: options.status } }) - const allClaims = db.Claim.findAndCountAll({ - limit: options.size, - offset: offset, - where: whereClause, - order: [['updatedAt', 'DESC']] - }) - - return Promise.all([distinctUsers, allClaims, distinctProjects]) -} - -function getClaimById(claimId) { - return db.Claim.findById(claimId) -} - -function delClaim(claimId) { - if (isNaN(+claimId)) { - return res.send('ClaimId must be a number') - } - return db.Claim.destroy({ - where: { - id: claimId - } - }) -} - -function updateClaim(claimId, { status, reason, bounty }) { - const claim = { - action: 'update', - claimId, - status, - bounty - } - fs.writeFile(__dirname + '/../audit/' + new Date().toISOString() + '.json', JSON.stringify(claim), () => {}) - - return db.Claim.update( - { - status: status, - reason: reason, - bounty: bounty - }, - { - where: { - id: claimId - }, - returning: true - } - ) -} - -function createClaim(user, issueUrl, pullUrl, bounty, status) { - const claim = { - action: 'create', - user, - issueUrl, - pullUrl, - bounty, - status - } - fs.writeFile(__dirname + '/../audit/' + new Date().toISOString() + '.json', JSON.stringify(claim), () => {}) - - return db.Claim.create({ - user, - issueUrl, - pullUrl, - repo: pullUrl.split('github.com/')[1].split('/')[1], - bounty: bounty, - status: status - }) -} - -function getLeaderboard(options = {}) { - options.size = parseInt(options.size || 0) - const offset = (options.page - 1) * options.size - - const userCount = db.Claim.aggregate('user', 'count', { distinct: true }) - - const results = db.Database.query(`SELECT "user", - SUM(CASE WHEN "claim"."status" = 'accepted' THEN "bounty" ELSE 0 END) as "bounty", - COUNT("bounty") as "pulls" - FROM "claims" AS "claim" - GROUP BY "user" - ORDER BY SUM(CASE WHEN "claim"."status" = 'accepted' THEN "bounty" ELSE 0 END) DESC, COUNT("bounty") DESC - LIMIT ${options.size} OFFSET ${offset}`) - - return Promise.all([userCount, results]) -} - -function getCounts() { - const participants = db.Claim.aggregate('user', 'count', { distinct: true }) - const claims = db.Claim.aggregate('*', 'count') - var accepted = db.Claim.aggregate('bounty', 'sum', { - where: { - status: 'accepted' - } - }) - var totalclaimed = db.Claim.aggregate('bounty', 'sum') - - var filterNaN = data => data || 0 - - var counts = Promise.all([participants, claims, accepted, totalclaimed]).then(values => values.map(filterNaN)) - - return counts -} - -module.exports = { - getClaims, - delClaim, - createClaim, - getLeaderboard, - getClaimById, - updateClaim, - getCounts -} diff --git a/routes/.root.js.swp b/routes/.root.js.swp deleted file mode 100644 index b899164..0000000 Binary files a/routes/.root.js.swp and /dev/null differ diff --git a/secret.json b/secret.json deleted file mode 100644 index b12e369..0000000 --- a/secret.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "secret": "someMuchSecretFFS", - "clientId": "7273335526", - "clientSecret": "VjmxuEwLqxsKsbl8VyUYr19Jg0Ag57SMwBB312f9nTkG8vJhNGp2pt2ywGnR4MxO", - "callbackURL": "http://localhost:3232/login/callback", - "BOSS_DB_NAME": "boss", - "BOSS_DB_USER": "postgres", - "BOSS_DB_PASS": "", - "BOSS_DB_HOST": "localhost" -} diff --git a/utils/.datautils.js.swp b/utils/.datautils.js.swp deleted file mode 100644 index 2aa0e77..0000000 Binary files a/utils/.datautils.js.swp and /dev/null differ