forked from openebs/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update top contributors as well as add new contributors
Signed-off-by: isamrish <askmaurya48@gmail.com>
- Loading branch information
Showing
9 changed files
with
442 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["fengye87","Nivedita Prasad (Nivedita-coder)","zeenix","liuminjian","Almas Ahmad (almas33)","dsavitskiy","sbidoul","aamirqs","burntcarrot","huangfangfeng"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["rakeshPRaghu","prateekpandey14","w3aman","Abhinandan-Purkait","nsathyaseelan","mynktl","niladrih","shubham14bajpai","satyapriyamishra222","AVRahul","Pallavi-PH","paulyoong","IsAmrish","tiagolobocastro","Ab-hishek","kmova","vharsh","cjones1024","gila","mittachaitu","rajaSahil","zeenix","jonathan-teh","pawanpraka1","dsavitskiy","mtzaurus","z0marlin","aamirqs","Abhishek-kumar09","akhilerm","almas33","AmitKumarDas","anupriya0703","fengye87","payes","shovanmaity"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const githubProfile = function(id) { | ||
if (id.indexOf('(') > -1) { | ||
id = id.substring(id.lastIndexOf('(') + 1, id.lastIndexOf(')')).trim(); | ||
} | ||
return `https://github.com/${id}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
const request = require("request"); | ||
const fs = require("fs"); | ||
|
||
const getdatesForContribution = (dateRange) => { | ||
const today = new Date(); | ||
const priorDate = new Date(); | ||
priorDate.setDate(priorDate.getDate() - dateRange); | ||
return { | ||
today, | ||
priorDate, | ||
todayTimestamp: today.valueOf(), | ||
priorDateTimestamp: priorDate.valueOf(), | ||
}; | ||
}; | ||
|
||
const dateRanges = { | ||
topContributors: 30, // last 30 days | ||
newContributors: 60, // last 60 days | ||
}; | ||
|
||
const rawSql = { | ||
topContributors: | ||
"select\n row_number() over (order by value desc) as \"Rank\",\n name,\n value\nfrom\n shpr_auth\nwhere\n series = 'hpr_authall'\n and period = 'm'", | ||
newContributors: | ||
"select str, dt from \"snew_contributors_data\" where $__timeFilter(dt) and series = 'ncdall' and period = 'd'", | ||
}; | ||
|
||
const reqBodyToFetchContributors = (type) => ({ | ||
queries: [ | ||
{ | ||
refId: "A", | ||
datasourceId: 1, | ||
rawSql: | ||
type === "topContributors" | ||
? rawSql.topContributors | ||
: rawSql.newContributors, | ||
format: "table", | ||
intervalMs: 86400000, | ||
maxDataPoints: 1255, | ||
}, | ||
], | ||
range: { | ||
from: | ||
type === "topContributors" | ||
? `${getdatesForContribution(dateRanges.topContributors).priorDate}` | ||
: `${getdatesForContribution(dateRanges.newContributors).priorDate}`, | ||
to: `${getdatesForContribution().today}`, | ||
raw: { | ||
from: | ||
type === "topContributors" | ||
? `now-${dateRanges.topContributors}d` | ||
: `now-${dateRanges.newContributors}d`, | ||
to: "now", | ||
}, | ||
}, | ||
from: | ||
type === "topContributors" | ||
? `${ | ||
getdatesForContribution(dateRanges.topContributors).priorDateTimestamp | ||
}` | ||
: `${ | ||
getdatesForContribution(dateRanges.newContributors).priorDateTimestamp | ||
}`, | ||
to: `${getdatesForContribution().todayTimestamp}`, | ||
}); | ||
|
||
const settings = (type) => ({ | ||
url: "https://openebs.devstats.cncf.io/api/ds/query", | ||
method: "POST", | ||
json: true, | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: reqBodyToFetchContributors(type), | ||
}); | ||
|
||
const fetchContributors = async () => { | ||
await request.post( | ||
settings("topContributors"), | ||
function (error, response, body) { | ||
if (error) { | ||
console.error(error); | ||
return; | ||
} | ||
const data = JSON.stringify(body?.results?.A?.frames[0]?.data?.values[1]); | ||
data && fs.writeFileSync("src/data/topContributors.json", data); | ||
} | ||
); | ||
|
||
await request.post( | ||
settings("newContributors"), | ||
function (error, response, body) { | ||
if (error) { | ||
console.error(error); | ||
return; | ||
} | ||
const data = JSON.stringify( | ||
body?.results?.A?.frames[0]?.data?.values[0]?.reverse() | ||
); | ||
data && fs.writeFileSync("src/data/newContributors.json", data); | ||
} | ||
); | ||
}; | ||
|
||
fetchContributors(); |
Oops, something went wrong.