add % counter
This commit is contained in:
parent
449c5d2523
commit
0d1c0a7a43
1 changed files with 13 additions and 10 deletions
11
site.js
11
site.js
|
@ -11,6 +11,8 @@ let userLimit = process.env.userLimit || Infinity;
|
||||||
let blacklist = (process.env.blacklist + '').split(',') || [];
|
let blacklist = (process.env.blacklist + '').split(',') || [];
|
||||||
let greylist = (process.env.greylist + '').split(',') || [];
|
let greylist = (process.env.greylist + '').split(',') || [];
|
||||||
let hh;
|
let hh;
|
||||||
|
let percent = 0;
|
||||||
|
let d = process.env.depth || 1;
|
||||||
|
|
||||||
async function urlCollector(url, path, file, useLimit, data2) {
|
async function urlCollector(url, path, file, useLimit, data2) {
|
||||||
if (path != 'following') return [];
|
if (path != 'following') return [];
|
||||||
|
@ -31,7 +33,6 @@ async function urlCollector(url, path, file, useLimit, data2) {
|
||||||
let ll = urls.length;
|
let ll = urls.length;
|
||||||
links.each(function (i, link) {
|
links.each(function (i, link) {
|
||||||
if (useLimit && urls.length >= pageLimit * 40 + ll) return;
|
if (useLimit && urls.length >= pageLimit * 40 + ll) return;
|
||||||
|
|
||||||
let h = body(link).attr('href');
|
let h = body(link).attr('href');
|
||||||
if (!h) return;
|
if (!h) return;
|
||||||
h = h.trim();
|
h = h.trim();
|
||||||
|
@ -80,6 +81,7 @@ async function rounder(users, data, mode) {
|
||||||
|
|
||||||
for (let u of users) {
|
for (let u of users) {
|
||||||
let it = 0;
|
let it = 0;
|
||||||
|
|
||||||
while (p.length >= (process.env.maxRate || 15)) {
|
while (p.length >= (process.env.maxRate || 15)) {
|
||||||
p = p.filter(x => x != 'hi');
|
p = p.filter(x => x != 'hi');
|
||||||
if (p.length == 0) break;
|
if (p.length == 0) break;
|
||||||
|
@ -101,7 +103,8 @@ async function rounder(users, data, mode) {
|
||||||
p.push(async function (k) {
|
p.push(async function (k) {
|
||||||
await siteCollector(u, 'followers', site, mode, data);
|
await siteCollector(u, 'followers', site, mode, data);
|
||||||
|
|
||||||
console.log(`User ${u} followers is fully calculated`);
|
percent += 50 / d / users.length;
|
||||||
|
console.log(`User ${u} followers is fully calculated (${percent}% total)`);
|
||||||
|
|
||||||
p[k] = 'hi';
|
p[k] = 'hi';
|
||||||
}(p.length));
|
}(p.length));
|
||||||
|
@ -109,7 +112,8 @@ async function rounder(users, data, mode) {
|
||||||
p.push(async function (k) {
|
p.push(async function (k) {
|
||||||
await siteCollector(u, 'following', site, mode, data);
|
await siteCollector(u, 'following', site, mode, data);
|
||||||
|
|
||||||
console.log(`User ${u} following is fully calculated`);
|
percent += 50 / d / users.length;
|
||||||
|
console.log(`User ${u} following is fully calculated (${percent}% total)`);
|
||||||
|
|
||||||
p[k] = 'hi';
|
p[k] = 'hi';
|
||||||
}(p.length));
|
}(p.length));
|
||||||
|
@ -235,7 +239,6 @@ async function siteCollector(user, path, site, useLimit, data2) {
|
||||||
|
|
||||||
users = [...new Set(users)];
|
users = [...new Set(users)];
|
||||||
|
|
||||||
let d = process.env.depth || 1;
|
|
||||||
for (let i = 1; i < d; i++) {
|
for (let i = 1; i < d; i++) {
|
||||||
let tempSet = [...users];
|
let tempSet = [...users];
|
||||||
users = await rounder(tempSet, data, true);
|
users = await rounder(tempSet, data, true);
|
||||||
|
|
Loading…
Reference in a new issue