Skip to content

Commit

Permalink
PP-12100 Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
james-peacock-gds committed Apr 8, 2024
1 parent b07eef5 commit 1ad677b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 1 addition & 5 deletions app/controllers/all-service-transactions/get.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ const logger = require('../../utils/logger')(__filename)
const { NoServicesWithPermissionError } = require('../../errors')

module.exports = async function getTransactionsForAllServices (req, res, next) {
//return response(req, res, 'transactions/index')

const filters = getFilters(req)
//console.log('filters: ' + JSON.stringify(filters))
//console.log('params:' + JSON.stringify(req.params))

// a filter param will be set on status specific routes, if they're not set the
// default behaviour should be live
Expand All @@ -44,7 +40,7 @@ module.exports = async function getTransactionsForAllServices (req, res, next) {

let searchResultOutput
try {
searchResultOutput = await transactionService.searchAllServices(userPermittedAccountsSummary.gatewayAccountIds, filters.result)
searchResultOutput = await transactionService.search(userPermittedAccountsSummary.gatewayAccountIds, filters.result, true)
} catch (error) {
return next(error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ const logger = require('../../utils/logger')(__filename)
const { NoServicesWithPermissionError } = require('../../errors')

module.exports = async function getTransactionsForAllServicesNoSearch (req, res, next) {
console.log('allservicesnosearch')
const model = {}
model.search_path = paths.allServiceTransactions.index
try {
return response(req, res, 'transactions/index', { })
return response(req, res, 'transactions/index', model)
} catch (err) {
next(new Error('Unable to fetch transaction information'))
}
Expand Down
9 changes: 7 additions & 2 deletions app/services/transaction.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ const connectorRefundFailureReasons = {
AMOUNT_BELOW_MINIMUM: 'amount_min_validation'
}

const searchLedger = async function searchLedger (gatewayAccountIds = [], filters) {
const searchLedger = async function searchLedger (gatewayAccountIds = [], filters, allServices = false) {
try {
return await Ledger.transactions(gatewayAccountIds, filters)
} catch (error) {
if (error.errorCode === 504) {
throw new GatewayTimeoutError('Your request has timed out. Please apply more filters and try again.')
if (allServices === true) {
throw new GatewayTimeoutForAllServicesSearchError('The "all services" search has timed out. Please apply more filters and try again.')
}
else {
throw new GatewayTimeoutError('Your request has timed out. Please apply more filters and try again.')
}
} else {
throw new Error('Unable to retrieve list of transactions or card types.')
}
Expand Down

0 comments on commit 1ad677b

Please sign in to comment.