dankgrinder 5.20.0 → 5.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/inventory.js +7 -1
- package/lib/grinder.js +7 -4
- package/package.json +1 -1
|
@@ -194,7 +194,7 @@ async function enrichItems(items) {
|
|
|
194
194
|
/**
|
|
195
195
|
* Check inventory for all pages and return full item list.
|
|
196
196
|
*/
|
|
197
|
-
async function runInventory({ channel, waitForDankMemer, client, accountId, redis }) {
|
|
197
|
+
async function runInventory({ channel, waitForDankMemer, client, accountId, redis, onPageProgress }) {
|
|
198
198
|
LOG.cmd(`${c.white}${c.bold}pls inv${c.reset}`);
|
|
199
199
|
|
|
200
200
|
await channel.send('pls inv');
|
|
@@ -218,6 +218,9 @@ async function runInventory({ channel, waitForDankMemer, client, accountId, redi
|
|
|
218
218
|
const allItems = [];
|
|
219
219
|
let { page, total } = parsePageInfo(response);
|
|
220
220
|
LOG.info(`[inv] Page ${page}/${total}`);
|
|
221
|
+
if (typeof onPageProgress === 'function') {
|
|
222
|
+
try { onPageProgress({ page, total }); } catch {}
|
|
223
|
+
}
|
|
221
224
|
const visitedPages = new Set([page]);
|
|
222
225
|
|
|
223
226
|
allItems.push(...parseInventoryPage(response));
|
|
@@ -316,6 +319,9 @@ async function runInventory({ channel, waitForDankMemer, client, accountId, redi
|
|
|
316
319
|
visitedPages.add(page);
|
|
317
320
|
pageChanged = true;
|
|
318
321
|
LOG.info(`[inv] Page ${page}/${total}`);
|
|
322
|
+
if (typeof onPageProgress === 'function') {
|
|
323
|
+
try { onPageProgress({ page, total }); } catch {}
|
|
324
|
+
}
|
|
319
325
|
break;
|
|
320
326
|
}
|
|
321
327
|
// Clear CV2 cache again for next retry
|
package/lib/grinder.js
CHANGED
|
@@ -1103,6 +1103,9 @@ class AccountWorker {
|
|
|
1103
1103
|
client: this.client,
|
|
1104
1104
|
accountId: this.account.id,
|
|
1105
1105
|
redis,
|
|
1106
|
+
onPageProgress: ({ page, total }) => {
|
|
1107
|
+
this.log('info', `Inventory pages: ${page}/${total}`);
|
|
1108
|
+
},
|
|
1106
1109
|
});
|
|
1107
1110
|
this.log('success', `Inventory: ${result.items?.length || 0} items, ⏣ ${(result.totalValue || 0).toLocaleString()} net`);
|
|
1108
1111
|
try {
|
|
@@ -2418,8 +2421,7 @@ async function start(apiKey, apiUrl) {
|
|
|
2418
2421
|
log('info', `${c.dim}Checking inventory for all ${workers.length} accounts...${c.reset}`);
|
|
2419
2422
|
let invDone = 0;
|
|
2420
2423
|
let invFailed = 0;
|
|
2421
|
-
|
|
2422
|
-
const w = workers[i];
|
|
2424
|
+
await Promise.all(workers.map(async (w, i) => {
|
|
2423
2425
|
const label = w?.username || w?.account?.label || w?.account?.id || `account-${i + 1}`;
|
|
2424
2426
|
log('info', `${c.dim}[inv-startup] ${i + 1}/${workers.length} ${label}${c.reset}`);
|
|
2425
2427
|
try {
|
|
@@ -2428,8 +2430,9 @@ async function start(apiKey, apiUrl) {
|
|
|
2428
2430
|
} catch {
|
|
2429
2431
|
invFailed++;
|
|
2430
2432
|
}
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
+
const invComplete = invDone + invFailed;
|
|
2434
|
+
log('info', `${c.dim}[inv-startup-progress] ${invComplete}/${workers.length} complete (${invDone} ok, ${invFailed} failed)${c.reset}`);
|
|
2435
|
+
}));
|
|
2433
2436
|
const invSummaryColor = invFailed > 0 ? c.yellow : c.green;
|
|
2434
2437
|
log('success', `${c.dim}Inventory phase complete: ${invSummaryColor}${invDone}/${workers.length}${c.reset}${c.dim} done${invFailed > 0 ? `, ${c.yellow}${invFailed} failed${c.reset}${c.dim}` : ''}. Starting grind loops...${c.reset}`);
|
|
2435
2438
|
|