1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Added some logs to show how much time was left

This commit is contained in:
Edward Badel 2021-06-28 12:00:49 -04:00
parent f99984c672
commit bee69802b8

View File

@ -5,7 +5,7 @@ const nodeFetch = require("node-fetch");
const APILink = "https://api.github.com/repos/tobspr/shapez.io";
const numOfReqPerPage = 100; // Max is 100, change to something lower if loads are too long
const personalAccessToken = "PUT TOKEN HERE";
const personalAccessToken = "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";
const JSONFileLocation = path.join(__dirname, "..", "contributors.json");
@ -73,6 +73,11 @@ async function sortPRs(prs) {
const contributors = new Map();
const translators = new Map();
const clearLine = () => {
process.stdout.moveCursor(0, -1); // up one line
process.stdout.clearLine(1);
};
for (let i = 0; i < prs.length; i++) {
let map;
@ -82,7 +87,13 @@ async function sortPRs(prs) {
if (!map.has(prs[i].username)) map.set(prs[i].username, []);
map.get(prs[i].username).push(prs[i]);
if (i !== 0) clearLine();
console.log(`PR's Downloaded: ${i} out of ${prs.length} (${prs.length - i} left)`);
}
clearLine();
console.log("Downloaded All PR's");
return {
contributors,
@ -151,7 +162,7 @@ async function tryToUpdateContributors() {
async function updateContributors() {
const allPrs = await downloadAllPrs();
console.log(`Received ${allPrs.length} PRs`);
console.log(`Discovered ${allPrs.length} PRs`);
const sorted = await sortPRs(allPrs);
@ -162,6 +173,21 @@ async function updateContributors() {
function gulpTaskContributors($, gulp) {
gulp.task("contributors.build", cb => tryToUpdateContributors().then(() => cb));
gulp.task("contributors.build.force", cb => updateContributors().then(() => cb));
gulp.task("contributors.test", async cb => {
const people = [];
for (let i = 0; i < 100; i++) people.push(i);
console.log("Starting");
for (let i = 0; i < 100; i++) {
console.log(`PR's Downloaded: ${i} out of ${people.length} (${people.length - i} left)`);
await new Promise(res => setTimeout(res, 100));
}
process.stdout.moveCursor(0, -1); // up one line
process.stdout.clearLine(1);
console.log("Finished");
});
}
module.exports = {