Further refactoring. Fixed actor pages and more.

This commit is contained in:
2019-12-31 03:12:52 +01:00
parent 1c43884102
commit 5a6bf2b42f
11 changed files with 206 additions and 137 deletions

View File

@@ -17,8 +17,8 @@ async function curateActor(actor) {
knex('media')
.where({ domain: 'actors', target_id: actor.id })
.orderBy('index'),
knex('social')
.where({ domain: 'actors', target_id: actor.id })
knex('actors_social')
.where('actor_id', actor.id)
.orderBy('platform', 'desc'),
]);
@@ -197,8 +197,7 @@ function curateSocialEntry(url, actorId) {
return {
url: match.url,
platform: match.platform,
domain: 'actors',
target_id: actorId,
actor_id: actorId,
};
}
@@ -207,10 +206,7 @@ async function curateSocialEntries(urls, actorId) {
return [];
}
const existingSocialLinks = await knex('social').where({
domain: 'actors',
target_id: actorId,
});
const existingSocialLinks = await knex('actors_social').where('actor_id', actorId);
return urls.reduce((acc, url) => {
const socialEntry = curateSocialEntry(url, actorId);
@@ -243,7 +239,7 @@ async function fetchActors(queryObject, limit = 100) {
async function storeSocialLinks(urls, actorId) {
const curatedSocialEntries = await curateSocialEntries(urls, actorId);
await knex('social').insert(curatedSocialEntries);
await knex('actors_social').insert(curatedSocialEntries);
}
async function storeActor(actor, scraped = false, scrapeSuccess = false) {
@@ -358,7 +354,7 @@ async function scrapeActors(actorNames) {
updateActor(profile, true, true),
// storeAvatars(profile, actorEntry),
storePhotos(profile.avatars, {
domain: 'actors',
domain: 'actor',
role: 'photo',
primaryRole: 'avatar',
targetId: actorEntry.id,