mirror of
https://github.com/wassname/compare_altcoin_development.git
synced 2026-06-27 16:45:06 +08:00
can can do github orgs, progbar
This commit is contained in:
+2
-1
@@ -14,6 +14,7 @@
|
|||||||
"gh.js": "^3.0.8",
|
"gh.js": "^3.0.8",
|
||||||
"jquery": "^3.1.1",
|
"jquery": "^3.1.1",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"moment": "^2.17.1"
|
"moment": "^2.17.1",
|
||||||
|
"nanobar": "^0.4.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -12,7 +12,7 @@
|
|||||||
<div>
|
<div>
|
||||||
|
|
||||||
<label><a href="https://github.com/settings/tokens">Github api token: </a></label>
|
<label><a href="https://github.com/settings/tokens">Github api token: </a></label>
|
||||||
<input id="token" placeholder="token" />
|
<input id="token" placeholder="token" value="1996bd63f4c524b4cd36499e3db39d321f0b39a7"/>
|
||||||
</div>
|
</div>
|
||||||
<button id="refresh">Refresh</button>
|
<button id="refresh">Refresh</button>
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
<script src="https://cdn.datatables.net/colreorder/1.3.2/js/dataTables.colReorder.min.js" charset="utf-8"></script>
|
<script src="https://cdn.datatables.net/colreorder/1.3.2/js/dataTables.colReorder.min.js" charset="utf-8"></script>
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/colreorder/1.3.2/css/colReorder.dataTables.min.css">
|
<link rel="stylesheet" href="https://cdn.datatables.net/colreorder/1.3.2/css/colReorder.dataTables.min.css">
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/nanobar/0.4.2/nanobar.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js" charset="utf-8"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js" charset="utf-8"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gh.js/3.0.8/gh.min.js" charset="utf-8"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/gh.js/3.0.8/gh.min.js" charset="utf-8"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.js" charset="utf-8"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.js" charset="utf-8"></script>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+35
-2
@@ -3,8 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
let gh = new GitHub(localStorage['gh_token'] || '')
|
let gh = new GitHub(localStorage['gh_token'] || '')
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
// cache and save github api token
|
// cache and save github api token
|
||||||
$('#token').val(localStorage['gh_token'])
|
$('#token').val(localStorage['gh_token'])
|
||||||
$('#token').on('change', function() {
|
$('#token').on('change', function() {
|
||||||
@@ -14,6 +14,16 @@ $(document).ready(function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
var MergeBySumingNumbers = objects =>
|
||||||
|
objects.reduce((s,r)=>{
|
||||||
|
Object.keys(r).map(key=>{
|
||||||
|
v = r[key]
|
||||||
|
if (typeof(v)==="number") s[key]=(s[key]||0)+v
|
||||||
|
else s[key] = v
|
||||||
|
})
|
||||||
|
return s
|
||||||
|
},{})
|
||||||
|
|
||||||
|
|
||||||
function promiseGitHubRepoStats(url) {
|
function promiseGitHubRepoStats(url) {
|
||||||
|
|
||||||
@@ -80,9 +90,32 @@ function promiseGitHubRepoStats(url) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return Promise.all([promiseStats, promiseContributors, promiseChanges, promiseCommits, promiseReleases]).then(data => _.merge(...data))
|
return Promise.all([promiseStats, promiseContributors, promiseChanges, promiseCommits, promiseReleases]).then(data => _.merge(...data))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function promiseGitHubRepoStatsMulti(repos){
|
||||||
|
return Promise.all(
|
||||||
|
repos.map(promiseGitHubRepoStats)
|
||||||
|
)
|
||||||
|
.then(MergeBySumingNumbers)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function promiseGitHubOrgStats(org){
|
||||||
|
var apiUrl = "orgs/" + org.replace('https://github.com/', '') + '/repos'
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
gh.get(apiUrl, {opts:{per_page:100}}, (err, response) => {
|
||||||
|
if (err)
|
||||||
|
reject(err)
|
||||||
|
else
|
||||||
|
resolve(response)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then(data => data.map(row=>row.full_name))
|
||||||
|
.then(promiseGitHubRepoStatsMulti)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function promiseBitbucketRepoStats(url) {
|
function promiseBitbucketRepoStats(url) {
|
||||||
url = url.replace('https://bitbucket.org/', 'https://api.bitbucket.org/2.0/repositories/')
|
url = url.replace('https://bitbucket.org/', 'https://api.bitbucket.org/2.0/repositories/')
|
||||||
|
|
||||||
|
|||||||
+83
-8
@@ -11,6 +11,56 @@ TODO:
|
|||||||
function renderUrl(data){return '<a href="'+data+'">'+data+'</a>'}
|
function renderUrl(data){return '<a href="'+data+'">'+data+'</a>'}
|
||||||
function renderDate(data){return data?moment(data).format('YYYY/MM/DD'):data}
|
function renderDate(data){return data?moment(data).format('YYYY/MM/DD'):data}
|
||||||
|
|
||||||
|
// ideally I want the input to bea list of github users or repos
|
||||||
|
var coins = {
|
||||||
|
"Bitcoin": 'https://github.com/bitcoin/bitcoin',
|
||||||
|
"Ethereum": 'https://github.com/ethereum/go-ethereum',
|
||||||
|
"Ripple": 'https://github.com/ripple/rippled',
|
||||||
|
"Litecoin": 'https://github.com/litecoin-project/litecoin',
|
||||||
|
"Monero": 'https://github.com/monero-project/monero',
|
||||||
|
'Dash': 'https://github.com/dashpay/dash',
|
||||||
|
"Augur": "https://github.com/AugurProject/augur-core",
|
||||||
|
"Maidsafe": "https://github.com/maidsafe/safe_client_libs",
|
||||||
|
"Steem": "https://github.com/steemit/steem",
|
||||||
|
"NEM": "https://github.com/NemProject/nem.core",
|
||||||
|
//'Iconomi':'',
|
||||||
|
"Factom": 'https://github.com/FactomProject/factomd',
|
||||||
|
'Dogecoin': 'https://github.com/dogecoin/dogecoin',
|
||||||
|
'Waves': 'https://github.com/wavesplatform/Waves',
|
||||||
|
'ZCash': 'https://github.com/zcash/zcash',
|
||||||
|
'DigixDAO': 'https://github.com/DigixGlobal/digixdao-contracts',
|
||||||
|
'Stellar Lumens': 'https://github.com/stellar/stellar-core',
|
||||||
|
'Lisk': 'https://github.com/LiskHQ/lisk',
|
||||||
|
'Tether': 'https://bitbucket.org/tetherto/tether-api-client-ruby',
|
||||||
|
// 'E-Dinar Coin': 'https://github.com/edincoin/EDINARCOIN',
|
||||||
|
//'ARDOR':'',
|
||||||
|
'GameCredits': 'https://github.com/gamecredits-project/GameCredits',
|
||||||
|
'Swiscoin': 'https://github.com/SCNPay/swiscoin',
|
||||||
|
'Bitshares': 'https://github.com/bitshares/bitshares-2',
|
||||||
|
/** Notable below top 25 **/
|
||||||
|
"Golem": "https://github.com/golemfactory/golem",
|
||||||
|
"PIVX":"https://github.com/PIVX-Project/PIVX",
|
||||||
|
"Nxt": 'https://bitbucket.org/JeanLucPicard/nxt', // bitbucket
|
||||||
|
"Iota": "https://github.com/iotaledger/iri",
|
||||||
|
"IotaOrg": "https://github.com/iotaledger",
|
||||||
|
"Vertcoin": 'https://github.com/vertcoin/vertcoin',
|
||||||
|
'Stratis': 'https://github.com/stratisproject/stratisX',
|
||||||
|
'VCash': 'https://github.com/openvcash/vcash',
|
||||||
|
"BitcoinUnlimited": "https://github.com/BitcoinUnlimited/BitcoinUnlimited",
|
||||||
|
"Bitcoinclassic": "https://github.com/bitcoinclassic/bitcoinclassic",
|
||||||
|
"Burstcoin": "https://github.com/BurstProject/burstcoin",
|
||||||
|
"Blocknet": "https://github.com/atcsecure/blocknet",
|
||||||
|
"Syscoin": "https://github.com/syscoin/syscoin2",
|
||||||
|
"Gnosis":"https://github.com/gnosis/gnosis-contracts",
|
||||||
|
// "":"https://github.com/voxelus"
|
||||||
|
"Qora": "https://github.com/Qoracoin/Qora",
|
||||||
|
"Storj": "https://github.com/Storj/core",
|
||||||
|
"Sia": "https://github.com/NebulousLabs/Sia",
|
||||||
|
"Bitcore": "https://github.com/dgbholdings/bitcore",
|
||||||
|
|
||||||
|
'Tittiecoin': 'https://github.com/tittiecoin/tittiecoin', // example shitcoin
|
||||||
|
}
|
||||||
|
|
||||||
var columns = [
|
var columns = [
|
||||||
{
|
{
|
||||||
"data": "coin",
|
"data": "coin",
|
||||||
@@ -166,7 +216,10 @@ function makeMarkDownTable(data) {
|
|||||||
|
|
||||||
/** fill missing attribtes so datatables stops complaining **/
|
/** fill missing attribtes so datatables stops complaining **/
|
||||||
function fillAll(data, columns){
|
function fillAll(data, columns){
|
||||||
return data.map(row=>{
|
// TODO log undefine and NaN rows
|
||||||
|
return data
|
||||||
|
.filter(_.isObject)
|
||||||
|
.map(row=>{
|
||||||
for (var i = 0; i < columns.length; i++) {
|
for (var i = 0; i < columns.length; i++) {
|
||||||
var key = columns[i].data
|
var key = columns[i].data
|
||||||
if (row[key]===undefined) row[key] = ''
|
if (row[key]===undefined) row[key] = ''
|
||||||
@@ -183,24 +236,46 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
// Collect data
|
// Collect data
|
||||||
let promises
|
let promises
|
||||||
|
var nanobar = new Nanobar({});
|
||||||
|
let total = Object.keys(coins).length
|
||||||
|
let finished_count = 0
|
||||||
if (!localStorage['gh-data'])
|
if (!localStorage['gh-data'])
|
||||||
promises = Promise.all(Object.keys(coins).map(coin => {
|
promises = Promise.all(Object.keys(coins).map(coin => {
|
||||||
var url = coins[coin]
|
var url = coins[coin]
|
||||||
|
// TODO(mjc) if its a user, list repos
|
||||||
|
// TODO(mjc) if url is a list, do promiseGitHubRepoStatsMulti
|
||||||
if (url.includes('github.com')) {
|
if (url.includes('github.com')) {
|
||||||
return promiseGitHubRepoStats(url).then(data => {
|
if (url.replace('https://github.com/','').includes('/')){
|
||||||
data.coin = coin
|
return promiseGitHubRepoStats(url).then(data => {
|
||||||
data.url = url
|
data.coin = coin
|
||||||
return data
|
data.url = url
|
||||||
})
|
return data
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return promiseGitHubOrgStats(url).then(data => {
|
||||||
|
data.coin = coin
|
||||||
|
data.url = url
|
||||||
|
return data
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return promiseBitbucketRepoStats(url).then(data => {
|
return promiseBitbucketRepoStats(url).then(data => {
|
||||||
data.coin = coin
|
data.coin = coin
|
||||||
data.url = url
|
data.url = url
|
||||||
return data
|
return data
|
||||||
})
|
}).catch(err => {console.error(err)})
|
||||||
}
|
}
|
||||||
|
|
||||||
}))
|
}).map(promise=>promise
|
||||||
|
.then(value => {
|
||||||
|
// progressbar
|
||||||
|
finished_count+=1
|
||||||
|
nanobar.go(finished_count/total*100)
|
||||||
|
return value
|
||||||
|
})
|
||||||
|
// .catch(err => {console.error(err)})
|
||||||
|
)
|
||||||
|
)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
// cache
|
// cache
|
||||||
localStorage['gh-data'] = JSON.stringify(data)
|
localStorage['gh-data'] = JSON.stringify(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user