-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
63 lines (52 loc) · 1.62 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
;/**
* Just an example of all the counters in action.
*/
const {
getBitbucketCounts,
getGitHubCounts,
getGitLabCounts,
} = require("contribution-counters");
// Luckily as my username and email addresses will be consistent throughout all 3 counters, use the same global variables
const username = "jahidulpabelislam";
const userEmailAddresses = [
];
const userNames = ["Jahidul Pabel Islam", "Jahidul Islam"];
// Keep count of all commits and projects throughout all 3 counters
let totalCommits = 0;
let totalProjects = 0;
// A generic wrapper function as all 3 counters are called the same way
const getCounts = async function(counterFunction, extraConfig = {}) {
const allConfig = {
username: username,
userEmailAddresses: userEmailAddresses,
userNames: userNames,
...extraConfig,
};
const counts = await counterFunction(allConfig);
// Here just update the total counts
totalCommits += counts.commits;
totalProjects += counts.projects;
};
const run = async function() {
await getCounts(getBitbucketCounts, {
accessToken: "hidden",
fromDate: "2019-06-02T00:00:00Z",
});
await getCounts(getGitHubCounts, {
accessToken: "hidden",
fromDate: "2019-06-02T00:00:00Z",
});
await getCounts(getGitLabCounts, {
accessToken: "hidden",
fromDate: "2019-06-02T00:00:00Z",
});
const counts = {
projects: totalProjects,
commits: totalCommits,
};
console.log("Total:", counts);
};
run();