Skip to content

Commit

Permalink
Fix: pubs with no discussions (#873)
Browse files Browse the repository at this point in the history
* check for no discussions and skip

* fix comment author issues

* do not pass in orcid if does not exist
  • Loading branch information
gabestein authored Dec 26, 2024
1 parent d82ab08 commit 22f3c03
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
23 changes: 20 additions & 3 deletions core/actions/googleDriveImport/formatDriveData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,23 @@ export const formatDriveData = async (
if (index === 0) {
firstCommentId = comment.id;
}
// we apparently can't assume the comment.author exists, sometimes it's comment.commenter
const commentAuthorName = comment.author
? comment.author.fullName
: comment.commenter
? comment.commenter.name
: "";
const commentAuthorAvatar = comment.author
? comment.author.avatar
: comment.commenter
? comment.commenter.avatar
: "";
const commentAuthorORCID =
comment.author && comment.author.orcid
? `https://orcid.org/${comment.author.orcid}`
: comment.commenter && comment.commenter.orcid
? `https://orcid.org/${comment.commenter.orcid}`
: null;
const commentObject: any = {
id: comment.id,
values: {
Expand All @@ -117,9 +134,9 @@ export const formatDriveData = async (
: undefined,
[`${communitySlug}:content`]: comment.text,
[`${communitySlug}:publication-date`]: comment.createdAt,
[`${communitySlug}:full-name`]: comment.author.fullName,
[`${communitySlug}:orcid`]: `https://orcid.org/${comment.author.orcid}`,
[`${communitySlug}:avatar`]: comment.author.avatar,
[`${communitySlug}:full-name`]: commentAuthorName,
[`${communitySlug}:orcid`]: commentAuthorORCID,
[`${communitySlug}:avatar`]: commentAuthorAvatar,
[`${communitySlug}:is-closed`]: discussion.isClosed,
[`${communitySlug}:parent-id`]:
index !== 0 ? firstCommentId : undefined,
Expand Down
7 changes: 5 additions & 2 deletions core/actions/googleDriveImport/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ export const run = defineRun<typeof action>(

// Check for legacy discussion IDs on platform
const legacyDiscussionIds = formattedData.discussions.map((pub) => pub.id);
const { pubs: existingPubs } = await doPubsExist(legacyDiscussionIds, communityId);
const existingDiscussionPubIds = existingPubs.map((pub) => pub.id);
const existingDiscussionPubIds: any[] = [];
if (legacyDiscussionIds.length > 0) {
const { pubs: existingPubs } = await doPubsExist(legacyDiscussionIds, communityId);
existingPubs.forEach((pub) => existingDiscussionPubIds.push(pub.id));
}

// Versions don't have IDs so we compare timestamps
const existingVersionDates = pub.values
Expand Down

0 comments on commit 22f3c03

Please sign in to comment.