Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Support cancelling a challenge#83

Merged
ThomasKranitsas merged 1 commit intomasterfromdevelop
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletionsrc/services/ProcessorService.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,7 @@ const metadataService = require('./metadataService')
const paymentService = require('./paymentService')
const { createOrSetNumberOfReviewers } = require('./selfServiceReviewerService')
const { disableTimelineNotifications } = require('./selfServiceNotificationService')
const legacyChallengeService = require('./legacyChallengeService')

/**
* Drop and recreate phases in ifx
Expand DownExpand Up@@ -656,7 +657,6 @@ async function processMessage (message) {
if (_.get(message, 'payload.legacy.selfService')) {
await disableTimelineNotifications(legacyId, createdByUserId) // disable
}

}

logger.debug('Result from parsePayload:')
Expand DownExpand Up@@ -734,6 +734,11 @@ async function processMessage (message) {
} else {
logger.info('Will skip syncing phases as the challenge is a task...')
}
if (message.payload.status === constants.challengeStatuses.CancelledClientRequest && challenge.currentStatus !== constants.challengeStatuses.CancelledClientRequest) {
logger.info('Cancelling challenge...')
await legacyChallengeService.cancelChallenge(legacyId, updatedByUserId)
needSyncV4ES = true
}
if (needSyncV4ES) {
try {
logger.info(`Resync V4 ES for the legacy challenge ${legacyId}`)
Expand Down
50 changes: 50 additions & 0 deletionssrc/services/legacyChallengeService.js
View file
Open in desktop
Original file line numberDiff line numberDiff 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
}

[8]ページ先頭

©2009-2025 Movatter.jp