这是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
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
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