Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Sync updates github docs parents Field #1296

Merged
merged 36 commits into from
Sep 8, 2023
Merged

Conversation

philipperolet
Copy link
Contributor

Based on the similar Notion PR for review simplicity (there is a common change)

Much, much, much simpler than Notion

Same migration plan

@@ -281,7 +281,7 @@ export async function githubUpsertDiscussionActivity(
documentUrl: discussion.url,
timestampMs: new Date(discussion.createdAt).getTime(),
tags,
parents: [],
parents: [discussionNumber.toString(), repoId.toString()],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentId should be visible here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise we risk divergence?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually maybe it's not documentid but at least should be a variable that is used to set the ressource internal Id ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since no valid external id exist I will use the pre-existing getIssueDocumentId here and document it; same for discussion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will document it very explicitly

@@ -154,7 +154,7 @@ export async function githubUpsertIssueActivity(
documentUrl: issue.url,
timestampMs: lastUpdateTimestamp,
tags: tags,
parents: [],
parents: [issueNumber.toString(), repoId.toString()],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, documentId should be visible otherwise we risk divergence?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually maybe it's not documentid but at least should be a variable that is used to set the ressource internal Id ?

fontanierh
fontanierh previously approved these changes Sep 7, 2023
Copy link
Contributor

@fontanierh fontanierh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome ! lgtm modulo spolu comments

: await Connector.findAll({
where: {
type: "github",
workspaceId: process.argv[2],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it doesn't matter much since it a one off, but curious what happens if I forget argv[2] ? Does it basically does the same as "all" because workspaceId: undefined doesn't filter ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Let's validate that

}

async function updateIssuesParentsFieldForConnector(connector: Connector) {
// get all distinct documentIds and their channel ids from slack messages in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comment seems wrong

},
attributes: ["repoId", "issueNumber"],
});
// update all parents fields for all pages and databases by chunks of 128
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comment looks wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You got me 😸 Draft wrote by copilot 🤖 and then I forgot to update the com

@philipperolet philipperolet requested a review from spolu September 7, 2023 16:59
// Therefore as a special case we use getIssueDocumentId() to get a parent string
parents: [
getIssueDocumentId(repoId.toString(), issue.number),
repoId.toString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity what does this Id look like? Is that a number?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have 2 github managed data sources I worry we'll be clashing, which means we should probably update the connectors resource API to use something more specific?

We want to make sure it's globally unique

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No clear doc about this, but I have created two repos at ~ 30mn interval and their repo ids are 688834560 and 688870568
Pretty sure it's an autoincremented primary key
=> I am willing to decide it is globally unique, and be responsible for the consequences if i'm wrong

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look long enough to me 👍 :)

Copy link
Contributor

@spolu spolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented on globally unique-ness otherwise LGTM

// Therefore as a special case we use getIssueDocumentId() to get a parent string
parents: [
getIssueDocumentId(repoId.toString(), issue.number),
repoId.toString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have 2 github managed data sources I worry we'll be clashing, which means we should probably update the connectors resource API to use something more specific?

We want to make sure it's globally unique

@philipperolet philipperolet requested a review from spolu September 8, 2023 09:30
spolu
spolu previously approved these changes Sep 8, 2023
Base automatically changed from ds-parents-field-notion to main September 8, 2023 10:19
@philipperolet philipperolet dismissed stale reviews from spolu and fontanierh September 8, 2023 10:19

The base branch was changed.

@spolu
Copy link
Contributor

spolu commented Sep 8, 2023

re last commit, you should use rebase instead of merging main 😬

@philipperolet
Copy link
Contributor Author

Ok. I was using the Github UI "resolve conflicts" since it was a small conflict easily solvable, linked to Github autorebasing this branch on main when I merged its base branch. I thought it was ok in that case.

Will systematically rebase from here on

@philipperolet philipperolet merged commit 7a20e7e into main Sep 8, 2023
3 checks passed
@philipperolet philipperolet deleted the ds-parents-github branch September 8, 2023 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants