yep
This commit is contained in:
1 parent
f0e204d70b
commit
76dc840cf7
11 files changed
+629
-40
No files matched your search
@@ -1,12 +1,43 @@
|
||||
import fs from 'fs/promises';
|
||||
import _ from 'lodash';
|
||||
|
||||
import discogsService from './src/discogs';
|
||||
import sellers from './sellers';
|
||||
|
||||
async function start() {
|
||||
const discogs = discogsService();
|
||||
// return discogs.wantlist('margh');
|
||||
return discogs.inventory(sellers[2]);
|
||||
const wants = JSON.parse(await fs.readFile('./data/margh.wantlist.json', { encoding: 'utf8' }))
|
||||
console.log('wants', wants.length);
|
||||
|
||||
|
||||
const listings = await Promise.all(wants.map(async w => {
|
||||
try {
|
||||
const l = await discogs.listings(w.id)
|
||||
return l;
|
||||
} catch (e) {
|
||||
// console.error(e);
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
// once we have all the listings
|
||||
// group by seller
|
||||
|
||||
return _
|
||||
.chain(listings)
|
||||
.filter(l => l)
|
||||
.reduce((acc, g) => acc.concat(g), [])
|
||||
.map(l => ({
|
||||
id: l.id,
|
||||
description: l.release.description,
|
||||
seller_id: l.seller.id,
|
||||
seller_name: l.seller.username,
|
||||
}))
|
||||
.groupBy(l => l.seller_id)
|
||||
.sortBy(s => s.length)
|
||||
.reverse()
|
||||
.head()
|
||||
.value();
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
Reference in new issue
Block a user