unistore sucks i think

This commit is contained in:
ntr committed 2022-08-01 18:29:23 +10:00
1 parent baeaead650
commit 02aadcf2db
21 files changed
+4468 -1354

No files matched your search

+9 -34
View File
@@ -8,40 +8,13 @@ import discogsService from './src/discogs';
import pgService from './src/pg';
import { logAxiosError } from './src/utils';
import createLog from './src/log';
import createApi from './src/api';
async function start(log) {
const prisma = new PrismaClient();
const pg = pgService(log, prisma);
const discogs = discogsService(log, pg);
async function getBundles() {
const bundles = await pg.bundleCandidates();
bundles.forEach(b => {
const data = b.map(l => l.data) as any[];
const wants = b.map(l => l.wantId);
const total = data.reduce((acc, l) => acc + l.price.value, 0);
const items = data.map(l => ({
id: l.id,
description: l.release.description,
price: l.price.value,
condition: l.condition,
uri: l.uri,
}));
const username = data[0]?.seller.username
const seller = data[0]?.seller.id
const shipsFrom = data[0]?.ships_from;
const currency = data[0]?.price.currency;
const shipping = data[0]?.seller.shipping;
const mentionsAustralia = shipping.toLowerCase().includes('australia');
const mentionsWorldwide = shipping.toLowerCase().includes('world');
log.info({ count: b.length, currency, total, items, username, seller, shipsFrom, mentionsAustralia, mentionsWorldwide });
});
// return bundles;
}
const api = createApi(log, pg);
const usernames = [
'vanderbabe',
@@ -65,12 +38,14 @@ async function start(log) {
});
}
await Promise.mapSeries(usernames, async u => {
const user = await discogs.user(u)
return populateUserListings(user);
});
// await Promise.mapSeries(usernames, async u => {
// const user = await discogs.user(u)
// return populateUserListings(user);
// });
return getBundles();
await api.listen();
// return getBundles();
}
async function run() {