-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix[smartling]: duplicate content entries handling #4169
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
base: main
Are you sure you want to change the base?
Changes from all commits
7ddec8f
4838ffe
e9cbfac
7991879
1e3bc10
7376805
dc4575a
2894710
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,14 +109,18 @@ export class SmartlingApi { | |
| } | ||
| async updateLocalJob(jobId: string, content: any[]) { | ||
| const latestDraft = await appState.getLatestDraft(jobId); | ||
| const allContent = [...content]; | ||
| const processedSymbols = new Set<string>(); // Avoid duplicates | ||
|
|
||
| // Get existing entries to check for duplicate symbols | ||
| // Get existing entries to check for duplicate content and symbols | ||
| const existingEntryIds = new Set((latestDraft.data.entries || []).map((entry: any) => entry.content?.id)); | ||
|
|
||
| // Filter out content that already exists in the job | ||
| const newContent = content.filter(c => !existingEntryIds.has(c.id)); | ||
|
|
||
| const allContent = [...newContent]; | ||
|
|
||
| // Extract and include symbol content for updates too | ||
| for (const contentItem of content) { | ||
| for (const contentItem of newContent) { | ||
| try { | ||
| // Fetch the full content to analyze for symbols | ||
| const fullContent = await fetch( | ||
|
|
@@ -159,7 +163,7 @@ export class SmartlingApi { | |
| published: 'draft', | ||
| }; | ||
|
|
||
| const symbolCount = allContent.length - content.length; | ||
| const symbolCount = allContent.length - newContent.length; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔question:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you check the code above allContent is getting updated. We add symbols to it |
||
| if (symbolCount > 0) { | ||
| } else { | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔question:
Curious Q: what happens when the smartling job is being processed and we update the content during that time ? Do we have to schedule new job ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could cause issues, not handling that right now. It would be a new feature request.