Skip to content

Commit

Permalink
Merge pull request #377 from bitfinexcom/staging
Browse files Browse the repository at this point in the history
Release version to master
  • Loading branch information
prdn authored May 8, 2024
2 parents 7821574 + 99f1629 commit 50dc1b4
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 16 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
linux-test-runner:
name: Linux Test Runner
timeout-minutes: 30
timeout-minutes: 90
runs-on: ubuntu-22.04
steps:
- name: Checkout
Expand All @@ -31,7 +31,14 @@ jobs:
- name: Install deps
run: npm i
- name: Run tests
run: npm test -- --reporter=json --reporter-option output=test-report.json
uses: nick-fields/retry@v3
continue-on-error: false
with:
timeout_minutes: 20
retry_wait_seconds: 10
max_attempts: 3
retry_on: any
command: npm test -- --reporter=json --reporter-option output=test-report.json
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bfx-reports-framework",
"version": "4.17.1",
"version": "4.17.2",
"description": "Bitfinex reports framework",
"main": "worker.js",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion test/1-api-sync-mode-sqlite.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('Sync mode API with SQLite', () => {
})

after(async function () {
this.timeout(5000)
this.timeout(20000)

await stopEnvironment()
await rmDB(dbDirPath)
Expand Down
2 changes: 1 addition & 1 deletion test/2-additional-api-sync-mode-sqlite.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Additional sync mode API with SQLite', () => {
})

after(async function () {
this.timeout(5000)
this.timeout(20000)

await stopEnvironment()
await rmDB(dbDirPath)
Expand Down
4 changes: 2 additions & 2 deletions test/3-api-filter-sync-mode-sqlite.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('API filter', () => {
const auth = { token: '' }

before(async function () {
this.timeout(5000)
this.timeout(20000)

mockRESTv2Srv = createMockRESTv2SrvWithDate(start, end, 10)

Expand All @@ -85,7 +85,7 @@ describe('API filter', () => {
})

after(async function () {
this.timeout(5000)
this.timeout(20000)

await stopEnvironment()
await rmDB(dbDirPath)
Expand Down
2 changes: 1 addition & 1 deletion test/4-sub-account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('Sub-account', () => {
})

after(async function () {
this.timeout(5000)
this.timeout(20000)

await stopEnvironment()
await rmDB(dbDirPath)
Expand Down
2 changes: 1 addition & 1 deletion test/5-recover-password.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('Recover password', () => {
})

after(async function () {
this.timeout(5000)
this.timeout(20000)

await stopEnvironment()
await rmDB(dbDirPath)
Expand Down
2 changes: 1 addition & 1 deletion test/6-update-sub-account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('Update sub-account', () => {
})

after(async function () {
this.timeout(5000)
this.timeout(20000)

await stopEnvironment()
await rmDB(dbDirPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class RecalcSubAccountLedgersBalancesHook extends DataInserterHook {
) {
return {
balance: _nativeBalance,
balanceUsd: _nativeBalanceUsd
balanceUsd: _nativeBalanceUsd,
_isBalanceRecalced: null
}
}

Expand Down Expand Up @@ -143,7 +144,8 @@ class RecalcSubAccountLedgersBalancesHook extends DataInserterHook {

return {
balance,
balanceUsd
balanceUsd,
_isBalanceRecalced: 1
}
}

Expand Down Expand Up @@ -316,11 +318,17 @@ class RecalcSubAccountLedgersBalancesHook extends DataInserterHook {
return
}

const authIds = [...auth]
.map(([key, auth]) => auth?._id)
.filter((id) => Number.isFinite(id))
const requiredUserIds = [...new Set(authIds)]

const firstNotRecalcedElem = await this.dao.getElemInCollBy(
tableName,
{
$isNotNull: 'subUserId',
$isNull: '_isBalanceRecalced'
$isNull: '_isBalanceRecalced',
$in: { user_id: requiredUserIds }
},
[['mts', 1], ['id', 1]]
)
Expand All @@ -346,6 +354,7 @@ class RecalcSubAccountLedgersBalancesHook extends DataInserterHook {
filter: {
$gte: { mts },
$nin: { _id: skipedIds },
$in: { user_id: requiredUserIds },
$isNotNull: 'subUserId'
},
sort: [['mts', 1], ['id', 1]],
Expand Down Expand Up @@ -377,7 +386,8 @@ class RecalcSubAccountLedgersBalancesHook extends DataInserterHook {
const _elem = elem ?? {}
const {
balance,
balanceUsd
balanceUsd,
_isBalanceRecalced
} = await this._getRecalcBalanceAsync(
auth,
recordsToGetBalances,
Expand All @@ -387,7 +397,7 @@ class RecalcSubAccountLedgersBalancesHook extends DataInserterHook {
recalcElems.push(Object.assign(_elem, {
balance,
balanceUsd,
_isBalanceRecalced: 1
_isBalanceRecalced
}))
}

Expand Down
10 changes: 10 additions & 0 deletions workers/loc.api/sync/data.inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ class DataInserter extends EventEmitter {

let count = 0
let serialRequestsCount = 0
let serialRequestsCountWithEndLessThanStart = 0
let prevRes = []

while (true) {
Expand Down Expand Up @@ -617,6 +618,15 @@ class DataInserter extends EventEmitter {
isAllData = true
}

// Prevent very rare issue: end <= start
if (currIterationArgs.params.start >= currIterationArgs.params.end) {
currIterationArgs.params.end = currIterationArgs.params.start + 1
serialRequestsCountWithEndLessThanStart += 1
}
if (serialRequestsCountWithEndLessThanStart > 1) {
isAllData = true
}

const normalizedApiData = normalizeApiData(res, model)

/*
Expand Down

0 comments on commit 50dc1b4

Please sign in to comment.