这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
4 changes: 3 additions & 1 deletion test/1-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,9 @@ describe('API', () => {
'priceAuxLimit',
'notify',
'placedId',
'amountExecuted'
'amountExecuted',
'routing',
'meta'
])
})

Expand Down
8 changes: 7 additions & 1 deletion test/helpers/mock-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,13 @@ module.exports = new Map([
null,
false,
null,
null
null,
null,
null,
'BFX',
null,
null,
{ _$F7: 1 }
]]
],
[
Expand Down
3 changes: 2 additions & 1 deletion workers/loc.api/generate-csv/csv.job.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ class CsvJobData {
priceTrailing: 'TRAILING PRICE',
mtsCreate: 'CREATED',
mtsUpdate: 'UPDATED',
status: 'STATUS'
status: 'STATUS',
meta: 'METADATA'
},
formatSettings: {
mtsUpdate: 'date',
Expand Down
17 changes: 12 additions & 5 deletions workers/loc.api/helpers/limit-param.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,26 @@ const getMethodLimit = (sendLimit, method, methodsLimits = {}) => {
} = selectedMethod
const {
isMax,
isInnerMax
isInnerMax,
isNotMoreThanInnerMax
} = { ...sendLimit }

const limit = Number.isInteger(sendLimit?.limit)
? sendLimit?.limit
: sendLimit
const base = Number.isInteger(limit)
? limit
: defVal

if (isInnerMax) {
return innerMax
}
if (isMax) {
return max
}

const base = Number.isInteger(sendLimit)
? sendLimit
: defVal
if (isNotMoreThanInnerMax) {
return getLimitNotMoreThan(base, innerMax)
}

return getLimitNotMoreThan(base, max)
}
Expand Down
25 changes: 16 additions & 9 deletions workers/loc.api/helpers/prepare-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ const _getParams = (
}

const { params } = { ...args }
const { isInnerMax } = { ...opts }
const { isInnerMax, isNotMoreThanInnerMax } = { ...opts }
const limit = isInnerMax
? { isInnerMax }
: params.limit
: { limit: params.limit, isNotMoreThanInnerMax }
const paramsObj = {
...cloneDeep(params),
end: getDateNotMoreNow(params.end),
Expand Down Expand Up @@ -329,11 +329,15 @@ const _isNotContainedSameMts = (
return false
}

const { isMax = true, isInnerMax } = { ...opts }
const {
isMax = true,
isInnerMax,
isNotMoreThanInnerMax
} = { ...opts }
const firstElem = { ...apiRes[0] }
const mts = firstElem[datePropName]
const methodLimit = getMethodLimit(
{ isMax, isInnerMax },
{ isMax, isInnerMax, isNotMoreThanInnerMax },
methodApi
)

Expand Down Expand Up @@ -484,7 +488,8 @@ const prepareApiResponse = (
datePropName,
symbPropName,
requireFields,
parseFieldsFn
parseFieldsFn,
isNotMoreThanInnerMax
} = { ...params }
const schemaName = _getSchemaNameByMethodName(methodApi)

Expand All @@ -498,17 +503,19 @@ const prepareApiResponse = (
getREST,
args,
methodApi,
symbPropName
symbPropName,
{ isNotMoreThanInnerMax }
)
const isNotContainedSameMts = _isNotContainedSameMts(
resData.apiRes,
methodApi,
datePropName,
resData.paramsObj.limit
resData.paramsObj.limit,
{ isNotMoreThanInnerMax }
)
const opts = isNotContainedSameMts
? { isMax: true }
: { isInnerMax: true }
? { isMax: true, isNotMoreThanInnerMax }
: { isInnerMax: true, isNotMoreThanInnerMax }
const {
apiRes,
paramsObj
Expand Down
15 changes: 14 additions & 1 deletion workers/loc.api/helpers/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,20 @@ const dateFormat = {
}
const language = {
type: 'string',
enum: ['en', 'ru', 'zh-CN', 'zh-TW', 'es-EM', 'tr', 'pt-PT']
enum: [
'en',
'en-US',
'ru',
'zh-CN',
'zh-TW',
'tr',
'tr-TR',
'es',
'es-EM',
'pt',
'pt-PT',
'pt-BR'
]
}

const paramsSchemaForPayInvoiceList = {
Expand Down
7 changes: 5 additions & 2 deletions workers/loc.api/queue/send-mail/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const fs = require('fs')
const pug = require('pug')
const yaml = require('js-yaml')

const LANGUAGES = require('./languages')

const basePathToViews = path.join(__dirname, 'views')
const pathToTrans = path.join(
__dirname,
Expand Down Expand Up @@ -79,7 +81,8 @@ module.exports = (grcBfxReq) => {
presigned_url: url,
language = 'en'
} = { ...data }
const translate = _getTranslator(language)
const normLang = LANGUAGES?.[language] ?? 'en'
const translate = _getTranslator(normLang)
const subject = translate(
configs.subject,
'template.subject'
Expand All @@ -104,7 +107,7 @@ module.exports = (grcBfxReq) => {
text,
subject,
button,
language
language: normLang
}

return grcBfxReq({
Expand Down
16 changes: 16 additions & 0 deletions workers/loc.api/queue/send-mail/languages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

module.exports = {
en: 'en',
'en-US': 'en',
ru: 'ru',
'zh-CN': 'zh-CN',
'zh-TW': 'zh-TW',
tr: 'tr',
'tr-TR': 'tr',
es: 'es-EM',
'es-EM': 'es-EM',
pt: 'pt-BR',
'pt-PT': 'pt-BR',
'pt-BR': 'pt-BR'
}
2 changes: 1 addition & 1 deletion workers/loc.api/queue/send-mail/translations/email.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ tr:
download: indir
pgpSignature: bir PGP dijital imza dosyası

pt-PT:
pt-BR:
template:
subject: Seu relatório está pronto
btnText: Baixar CSV
Expand Down
23 changes: 17 additions & 6 deletions workers/loc.api/service.report.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ class ReportService extends Api {

getTickersHistory (space, args, cb) {
return this._responder(() => {
const { symbol: s } = { ...args.params }
const {
params,
isNotMoreThanInnerMax
} = args ?? {}
const { symbol: s } = params ?? {}
const symbol = s && typeof s === 'string'
? [s]
: s
Expand All @@ -244,7 +248,8 @@ class ReportService extends Api {
'tickersHistory',
{
datePropName: 'mtsUpdate',
requireFields: ['symbol']
requireFields: ['symbol'],
isNotMoreThanInnerMax
}
)
}, 'getTickersHistory', args, cb)
Expand Down Expand Up @@ -353,6 +358,7 @@ class ReportService extends Api {

getPublicTrades (space, args, cb) {
return this._responder(() => {
const { isNotMoreThanInnerMax } = args ?? {}
const _args = {
...args,
auth: {}
Expand All @@ -362,7 +368,8 @@ class ReportService extends Api {
_args,
'publicTrades',
{
datePropName: 'mts'
datePropName: 'mts',
isNotMoreThanInnerMax
}
)
}, 'getPublicTrades', args, cb)
Expand Down Expand Up @@ -399,11 +406,14 @@ class ReportService extends Api {

getCandles (space, args, cb) {
return this._responder(() => {
const { params } = { ...args }
const {
params,
isNotMoreThanInnerMax
} = args ?? {}
const {
section = 'hist',
timeframe = '1D'
} = { ...params }
} = params ?? {}
const _args = {
...args,
auth: {},
Expand All @@ -418,7 +428,8 @@ class ReportService extends Api {
_args,
'candles',
{
datePropName: 'mts'
datePropName: 'mts',
isNotMoreThanInnerMax
}
)
}, 'getCandles', args, cb)
Expand Down