This repository was archived by the owner on Jan 23, 2025. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork6
Support cancelling a challenge#83
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
7 changes: 6 additions & 1 deletionsrc/services/ProcessorService.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletionssrc/services/legacyChallengeService.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /** | ||
| * Legacy Challenge Service | ||
| * Interacts with InformixDB | ||
| */ | ||
| const logger = require('../common/logger') | ||
| const util = require('util') | ||
| const helper = require('../common/helper') | ||
| const { createChallengeStatusesMap } = require('../constants') | ||
| const QUERY_UPDATE_PROJECT = 'UPDATE project SET project_status_id = ?, modify_user = ? WHERE project_id = %d' | ||
| /** | ||
| * Prepare Informix statement | ||
| * @param {Object} connection the Informix connection | ||
| * @param {String} sql the sql | ||
| * @return {Object} Informix statement | ||
| */ | ||
| async function prepare (connection, sql) { | ||
| // logger.debug(`Preparing SQL ${sql}`) | ||
| const stmt = await connection.prepareAsync(sql) | ||
| return Promise.promisifyAll(stmt) | ||
| } | ||
| /** | ||
| * Update a challenge in IFX | ||
| * @param {Number} challengeLegacyId the legacy challenge ID | ||
| * @param {Number} createdBy the creator user ID | ||
| */ | ||
| async function cancelChallenge (challengeLegacyId, createdBy) { | ||
| const connection = await helper.getInformixConnection() | ||
| let result = null | ||
| try { | ||
| await connection.beginTransactionAsync() | ||
| const query = await prepare(connection, util.format(QUERY_UPDATE_PROJECT, challengeLegacyId)) | ||
| result = await query.executeAsync([createChallengeStatusesMap.CancelledClientRequest, createdBy]) | ||
| await connection.commitTransactionAsync() | ||
| } catch (e) { | ||
| logger.error(`Error in 'cancelChallenge' ${e}, rolling back transaction`) | ||
| await connection.rollbackTransactionAsync() | ||
| throw e | ||
| } finally { | ||
| logger.info(`Challenge ${challengeLegacyId} has been cancelled`) | ||
| await connection.closeAsync() | ||
| } | ||
| return result | ||
| } | ||
| module.exports = { | ||
| cancelChallenge | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.