-
Notifications
You must be signed in to change notification settings - Fork 4
Mediawiki changes #481
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
Mediawiki changes #481
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -140,23 +140,16 @@ const handleHivemindWebsiteCase = async (platform: any) => { | |||||
| * @param {Object} platform - Platform object | ||||||
| */ | ||||||
| const handleHivemindMediaWikiCase = async (platform: any) => { | ||||||
| console.log('Handling Hivemind MediaWiki case for platform:', platform); | ||||||
| const platformDoc = await platformService.getPlatformById(platform.platform); | ||||||
|
|
||||||
| if (!platformDoc) return; | ||||||
|
|
||||||
| const isActivated = platform.metadata?.activated; | ||||||
| const existingWorkflowId = platformDoc.get('metadata.workflowId'); | ||||||
|
|
||||||
| if (isActivated === true) { | ||||||
| console.log('Platform is activated, checking for existing workflow ID:', existingWorkflowId); | ||||||
| if (!existingWorkflowId) { | ||||||
| console.log('No existing workflow ID found, executing new workflow for platform:', platform.platform); | ||||||
| const workflowId = await temporalMediaWiki.executeWorkflow(platform.platform); | ||||||
| console.log('New workflow ID created:', workflowId); | ||||||
| platformDoc.set('metadata.workflowId', workflowId); | ||||||
| await platformDoc.save(); | ||||||
| } | ||||||
| temporalMediaWiki.executeWorkflow(platformDoc.id); | ||||||
| } else if (isActivated === false) { | ||||||
| temporalMediaWiki.terminateWorkflow(platformDoc.id); | ||||||
|
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. Missing await for workflow termination. The workflow termination call is not awaited, which could lead to the function returning before the workflow is actually terminated. This may cause issues if the platform state depends on the workflow being stopped. Apply this diff to fix the async operation: - temporalMediaWiki.terminateWorkflow(platformDoc.id);
+ await temporalMediaWiki.terminateWorkflow(platformDoc.id);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| } | ||||||
| }; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,29 +12,26 @@ const logger = parentLogger.child({ module: 'MediaWikiTemporalService' }); | |||||||||||||||||||||||
| class TemporalMediaWikiService extends TemporalCoreService { | ||||||||||||||||||||||||
| public async executeWorkflow(platformId: Types.ObjectId) { | ||||||||||||||||||||||||
| const client: Client = await this.getClient(); | ||||||||||||||||||||||||
| const payload = { | ||||||||||||||||||||||||
| platform_id: platformId, | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
| const payload = platformId; | ||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| const workflowHandle = await client.workflow.execute('MediaWikiETLWorkflow', { | ||||||||||||||||||||||||
| client.workflow.execute('MediaWikiETLWorkflow', { | ||||||||||||||||||||||||
| taskQueue: queues.TEMPORAL_QUEUE_PYTHON_HEAVY, | ||||||||||||||||||||||||
| args: [payload], | ||||||||||||||||||||||||
| workflowId: `mediawiki/${platformId}/${uuidv4()}`, | ||||||||||||||||||||||||
| workflowId: `api:mediawikietl:${platformId}`, | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
Comment on lines
+17
to
21
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. Missing await for workflow execution. The workflow execution is not awaited, which means the method will return immediately without waiting for the workflow to start. This could lead to race conditions or make error handling ineffective. Apply this diff to fix the async operation: - client.workflow.execute('MediaWikiETLWorkflow', {
+ await client.workflow.execute('MediaWikiETLWorkflow', {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| logger.info(`Started MediaWiki workflow with ID: ${workflowHandle}`); | ||||||||||||||||||||||||
| return workflowHandle; | ||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||
| logger.error(`Failed to trigger MediaWiki workflow: ${(error as Error).message}`); | ||||||||||||||||||||||||
| throw new Error(`Failed to trigger MediaWiki workflow: ${(error as Error).message}`); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public async terminateWorkflow(workflowId: string): Promise<void> { | ||||||||||||||||||||||||
| public async terminateWorkflow(platformId: Types.ObjectId): Promise<void> { | ||||||||||||||||||||||||
| const client: Client = await this.getClient(); | ||||||||||||||||||||||||
| const handle = client.workflow.getHandle(workflowId); | ||||||||||||||||||||||||
| const description = await handle.describe(); | ||||||||||||||||||||||||
| if (description.status.name !== 'TERMINATED' && description.status.name !== 'COMPLETED') { | ||||||||||||||||||||||||
| await handle.terminate('Terminated due to schedule deletion'); | ||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| client.workflow.getHandle(`api:mediawikietl:${platformId}`).terminate(); | ||||||||||||||||||||||||
|
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. Missing await for workflow termination. The workflow termination is not awaited, which means the method will return before the termination completes. This could lead to inconsistent state or ineffective error handling. Apply this diff to fix the async operation: - client.workflow.getHandle(`api:mediawikietl:${platformId}`).terminate();
+ await client.workflow.getHandle(`api:mediawikietl:${platformId}`).terminate();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||
| logger.error(`Failed to terminate MediaWiki workflow: ${(error as Error).message}`); | ||||||||||||||||||||||||
| throw new Error(`Failed to terminate MediaWiki workflow: ${(error as Error).message}`); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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.
Missing await for workflow execution.
The workflow execution call is not awaited, which could lead to the function returning before the workflow starts. This may cause issues if subsequent operations depend on the workflow being active.
Apply this diff to fix the async operation:
📝 Committable suggestion
🤖 Prompt for AI Agents