Skip to content

Commit a825394

Browse files
committed
don't fetch stuff that's not necessary
People can write custom layouts that don't use maintainer name or node versions. This allows to turn off those in config.
1 parent 5416518 commit a825394

File tree

3 files changed

+39
-15
lines changed

3 files changed

+39
-15
lines changed

src/config.js

+16
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ config.projects = config.projects.map(function(project) {
5050
return project
5151
})
5252

53+
//
54+
// list of strings -> object
55+
// i.e. ['foo', 'bar', 'baz'] -> {foo: true, bar: true, baz: true}
56+
//
57+
if (config['db.json']) {
58+
for (var k in config['db.json']) {
59+
if (Array.isArray(config['db.json'][k])) {
60+
var t = {}
61+
config['db.json'][k].forEach(function(v) {
62+
t[v] = true
63+
})
64+
config['db.json'][k] = t
65+
}
66+
}
67+
}
68+
5369
//
5470
// helpers
5571
//

src/config.yaml

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@ title: badgeboard
1010
description: project status at a glance
1111
keywords: badgeboard, repo-utils
1212

13-
# this determines what info will be fetched with `make db`;
14-
# you can comment out stuff to reduce number of http requests
15-
db.json:
16-
projects:
17-
- node # node version, it's the lowest version from .travis.yml
18-
- description # package description from package.json (from npm registry)
19-
- maintainer # maintainer npm account (= _npmUser of last published ver)
20-
maintainers:
21-
- projects # amount of projects this npm user has
22-
- avatar # gravatar displayed on npm website
23-
2413
# list of projects, this will be sorted by name;
2514
# every package is either string or object
2615
projects:
@@ -58,3 +47,14 @@ maintainers:
5847
npm: rlidwka
5948
twitter: rlidwka
6049
email: alex@kocharin.ru
50+
51+
# this determines what info will be fetched with `make db`;
52+
# you can comment out stuff to reduce number of http requests
53+
db.json:
54+
projects:
55+
- node # node version, it's the lowest version from .travis.yml
56+
- description # package description from package.json (from npm registry)
57+
- maintainer # maintainer npm account (= _npmUser of last published ver)
58+
maintainers:
59+
- packages # amount of packages this npm user has
60+
- avatar # gravatar displayed on npm website

src/make-db.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ var data = {
1212
projects: {},
1313
maintainers: {},
1414
}
15-
var maintainersDB = require('./config').maintainers
15+
var config = require('./config')
16+
var maintainersDB = config.maintainers
1617
maintainersDB.forEach(function (maintainer) {
1718
data.maintainers[maintainer.npm] = {}
1819
})
19-
var projectsDB = require('./config').projects
20+
var projectsDB = config.projects
2021
projectsDB.forEach(function (project) {
2122
data.projects[project.name] = {}
2223
})
@@ -60,12 +61,18 @@ function *getOwnedPackages(user) {
6061
function *getMaintainersInfo() {
6162
for (var name in data.maintainers) {
6263
var mData = data.maintainers[name]
63-
mData.packages = yield getOwnedPackages(name)
64-
mData.avatar = (yield getUserInfo(name)).avatar
64+
if (config['db.json'].maintainers.packages)
65+
mData.packages = yield getOwnedPackages(name)
66+
67+
if (config['db.json'].maintainers.avatar)
68+
mData.avatar = (yield getUserInfo(name)).avatar
6569
}
6670
}
6771

6872
function *getInfoFromNpm() {
73+
if (!config['db.json'].projects.maintainer
74+
&& !config['db.json'].projects.description) return
75+
6976
for (var i=0; i<projectsDB.length; i++) {
7077
var project = projectsDB[i]
7178
var npm = yield getNpmInfo(project.npm)
@@ -77,6 +84,7 @@ function *getInfoFromNpm() {
7784
}
7885

7986
function *getInfoFromGithub() {
87+
if (!config['db.json'].projects.node) return
8088
for (var i=0; i<projectsDB.length; i++) {
8189
var project = projectsDB[i]
8290
var travis = yield getTravis(project.repo)

0 commit comments

Comments
 (0)