Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timing to 2PT matching service #346

Merged
merged 1 commit into from
Aug 9, 2023
Merged
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
12 changes: 12 additions & 0 deletions app/services/check/two-part.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const DetermineBillingPeriodsService = require('../billing/determine-billing-per
const ReturnModel = require('../../models/returns/return.model.js')

async function go (naldRegionId, format = 'friendly') {
const startTime = process.hrtime.bigint()

const billingPeriods = DetermineBillingPeriodsService.go()

const billingPeriod = billingPeriods[1]
Expand All @@ -25,6 +27,8 @@ async function go (naldRegionId, format = 'friendly') {

const matchedChargeVersions = _matchChargeVersions(chargeVersions)

_calculateAndLogTime(startTime)

switch (format) {
case 'friendly':
return _friendlyResponse(matchedChargeVersions)
Expand Down Expand Up @@ -129,6 +133,14 @@ function _friendlyResponse (_matchedChargeVersions) {
return { hello: 'world' }
}

function _calculateAndLogTime (startTime) {
const endTime = process.hrtime.bigint()
const timeTakenNs = endTime - startTime
const timeTakenMs = timeTakenNs / 1000000n

global.GlobalNotifier.omg('Two part tariff matching complete', { timeTakenMs })
}

module.exports = {
go
}