Showing number of newly added creators in ManyVids seed.
This commit is contained in:
@@ -7,7 +7,7 @@ const limit = Number(process.env.MV_LIMIT) || 1000;
|
|||||||
const sorting = process.env.MV_SORT || 'followers'; // followers, top, mostActive, newest, trending
|
const sorting = process.env.MV_SORT || 'followers'; // followers, top, mostActive, newest, trending
|
||||||
|
|
||||||
async function fetchCreators(page = 1, acc = []) {
|
async function fetchCreators(page = 1, acc = []) {
|
||||||
console.log(`Fetching creators ${acc.length}/${limit}`);
|
console.log(`Fetching ${acc.length}/${limit} creators by ${sorting}`);
|
||||||
|
|
||||||
// size seems to be capped at 70
|
// size seems to be capped at 70
|
||||||
const res = await unprint.get(`https://api.manyvids.com/search/creators/list?contentPref=1,2,3&sort=${sorting}&size=50&from=${(page - 1) * 50}`);
|
const res = await unprint.get(`https://api.manyvids.com/search/creators/list?contentPref=1,2,3&sort=${sorting}&size=50&from=${(page - 1) * 50}`);
|
||||||
@@ -42,7 +42,7 @@ exports.seed = async function (knex) {
|
|||||||
throw new Error('ManyVids found, did the network migration run?');
|
throw new Error('ManyVids found, did the network migration run?');
|
||||||
}
|
}
|
||||||
|
|
||||||
await knex('entities')
|
const result = await knex('entities')
|
||||||
.insert(channels.map((channel) => ({
|
.insert(channels.map((channel) => ({
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
slug: channel.slug,
|
slug: channel.slug,
|
||||||
@@ -51,7 +51,8 @@ exports.seed = async function (knex) {
|
|||||||
has_logo: false,
|
has_logo: false,
|
||||||
})))
|
})))
|
||||||
.onConflict(['slug', 'type'])
|
.onConflict(['slug', 'type'])
|
||||||
.merge(['name', 'url']);
|
.merge(['name', 'url'])
|
||||||
|
.returning(knex.raw('(xmax = 0) as inserted'));
|
||||||
|
|
||||||
console.log(`Done! ${channels.length} ManyVids creators added as channels`);
|
console.log(`Done! ${result.filter((row) => row.inserted).length}/${channels.length} ManyVids creators newly added as channels`);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user