这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 5 additions & 24 deletions workers/loc.api/generate-report-file/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict'

const {
FILTER_API_METHOD_NAMES,
normalizeFilterParams
FILTER_API_METHOD_NAMES
} = require('../helpers')
const {
getFilterValidationSchemaId
Expand Down Expand Up @@ -74,49 +73,31 @@ const _filterApiMethodNameMap = Object.values(FILTER_API_METHOD_NAMES)
return map
}, new Map())

const _truncateFileNameEnding = (name) => {
if (!name) {
return name
}

const cleanedName = name
.replace(/^get/i, '')
.replace(/(file)|(csv)$/i, '')

return `${cleanedName[0].toLowerCase()}${cleanedName.slice(1)}`
}

const _getFilterApiMethodNamesAndArgs = (
name,
reqArgs
args
) => {
if (name !== 'getMultipleFileJobData') {
const filterApiMethodName = _filterApiMethodNameMap.get(name)
const truncatedName = _truncateFileNameEnding(name)
const args = normalizeFilterParams(truncatedName, reqArgs)

return [{
filterApiMethodName,
args
}]
}

const { params } = { ...reqArgs }
const { multiExport } = { ...params }
const multiExport = args?.params?.multiExport ?? []
const _multiExport = Array.isArray(multiExport)
? multiExport
: []

return _multiExport.map((params) => {
const { method } = { ...params }
const name = `${method}JobData`
const truncatedName = _truncateFileNameEnding(method)
const args = normalizeFilterParams(truncatedName, { params })
const name = `${params?.method}JobData`
const filterApiMethodName = _filterApiMethodNameMap.get(name)

return {
filterApiMethodName,
args
args: { params }
}
})
}
Expand Down
2 changes: 0 additions & 2 deletions workers/loc.api/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const checkJobAndGetUserData = require(
)
const grcBfxReq = require('./grc-bfx-req')
const filterResponse = require('./filter-response')
const normalizeFilterParams = require('./normalize-filter-params')
const FILTER_API_METHOD_NAMES = require('./filter.api.method.names')
const FILTER_CONDITIONS = require('./filter.conditions')
const getDataFromApi = require('./get-data-from-api')
Expand Down Expand Up @@ -110,7 +109,6 @@ module.exports = {
checkJobAndGetUserData,
grcBfxReq,
filterResponse,
normalizeFilterParams,
FILTER_API_METHOD_NAMES,
FILTER_CONDITIONS,
getDataFromApi,
Expand Down
100 changes: 0 additions & 100 deletions workers/loc.api/helpers/normalize-filter-params.js

This file was deleted.

6 changes: 2 additions & 4 deletions workers/loc.api/helpers/prepare-response/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const { MinLimitParamError } = require('../../errors')

const filterResponse = require('../filter-response')
const normalizeFilterParams = require('../normalize-filter-params')

const prepareSymbolResponse = require('./prepare-symbol-response')

Expand Down Expand Up @@ -130,7 +129,7 @@ const prepareApiResponse = (
getREST,
dataValidator
) => async (
reqArgs,
args,
apiMethodName,
params = {}
) => {
Expand All @@ -143,8 +142,7 @@ const prepareApiResponse = (
const schemaId = getValidationSchemaId(apiMethodName)
const filterSchemaId = getFilterValidationSchemaId(apiMethodName)

await dataValidator.validate(reqArgs, schemaId)
const args = normalizeFilterParams(apiMethodName, reqArgs)
await dataValidator.validate(args, schemaId)
await dataValidator.validate(
{ params: args?.params?.filter },
filterSchemaId
Expand Down