Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion workers/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { WorkerTask } from 'server/models';
import { expect } from 'utils/assert';
import { createCachePurgeDebouncer } from 'utils/caching/createCachePurgeDebouncer';

const maxWorkerTimeSeconds = 120;
const maxWorkerTimeSeconds = 300;
const maxWorkerThreads = 5;
let currentWorkerThreads = 0;

Expand Down
22 changes: 14 additions & 8 deletions workers/tasks/import/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { metaValueToString, metaValueToJsonSerializable } from '@pubpub/prosemir

import { getSearchUsers } from 'server/search/queries';
import { isValidDate } from 'utils/dates';
import { asyncMap } from 'utils/async';
import { Falsy } from 'types';

const getAuthorsArray = (author) => {
Expand All @@ -23,18 +24,23 @@ const getDateStringFromMetaValue = (metaDateString) => {
return null;
};

const getAuthorEntries = async (authorEntry) => {
if (typeof authorEntry === 'string') {
const users = await getSearchUsers(authorEntry);
return { name: authorEntry, users: users.map((user) => user.toJSON()) };
}
return authorEntry;
};
const getAttributions = async (author) => {
if (author) {
const authorsArray = getAuthorsArray(author);
const authorEntries = authorsArray.map(metaValueToJsonSerializable) as any[];
const attributions = await Promise.all(
authorEntries.map(async (authorEntry: string) => {
if (typeof authorEntry === 'string') {
const users = await getSearchUsers(authorEntry);
return { name: authorEntry, users: users.map((user) => user.toJSON()) };
}
return authorEntry;
}),
const attributions = await asyncMap(
authorEntries,
(authorEntry) => getAuthorEntries(authorEntry),
{
concurrency: 2,
},
);
return attributions;
}
Expand Down