Skip to content

Commit

Permalink
parseInt instead of round && replacing underscores w/ dashes
Browse files Browse the repository at this point in the history
  • Loading branch information
justinlevi committed Nov 4, 2020
1 parent 0d811e7 commit 2756587
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions services/api/src/models/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,11 @@ export const EnvironmentModel = (clients) => {

const legacyBuckets = legacyResult && legacyResult.aggregations && legacyResult.aggregations.hourly && legacyResult.aggregations.hourly.buckets ? legacyResult.aggregations.hourly.buckets : 0;
const legacyResultCount = legacyResult && legacyResult.aggregations && legacyResult.aggregations.hourly && legacyResult.aggregations.hourly.buckets && legacyResult.aggregations.hourly.buckets.length ? legacyResult.aggregations.hourly.buckets.length : 0;
const legacyAvg = legacyResult && legacyResult.aggregations && legacyResult.aggregations.average && legacyResult.aggregations.average.value ? Math.round(legacyResult.aggregations.average.value) : 0;
const legacyAvg = legacyResult && legacyResult.aggregations && legacyResult.aggregations.average && legacyResult.aggregations.average.value ? parseInt(legacyResult.aggregations.average.value) : 0;

const newBuckets = newResult && newResult.aggregations && newResult.aggregations.hourly && newResult.aggregations.hourly.buckets ? newResult.aggregations.hourly.buckets : 0;
const newResultCount = newResult && newResult.aggregations && newResult.aggregations.hourly && newResult.aggregations.hourly.buckets && newResult.aggregations.hourly.buckets.length ? newResult.aggregations.hourly.buckets.length : 0;
const newAvg = newResult && newResult.aggregations && newResult.aggregations.average && newResult.aggregations.average.value ? Math.round(newResult.aggregations.average.value) : 0;
const newAvg = newResult && newResult.aggregations && newResult.aggregations.average && newResult.aggregations.average.value ? parseInt(newResult.aggregations.average.value) : 0;


/*
Expand All @@ -449,7 +449,7 @@ export const EnvironmentModel = (clients) => {
total += legacyBuckets[i].count.value;
}else{
// Both legacy and new logging buckets are zero, meaning we have missing data, use the avg
if(newAvg !== 0){
if(newAvg !== 0 && newAvg > legacyAvg){
total += newAvg;
}else if (legacyAvg !== 0){
total += legacyAvg;
Expand Down Expand Up @@ -489,7 +489,7 @@ export const EnvironmentModel = (clients) => {
interestedDateEnd.setUTCMilliseconds(999);
const interestedDateEndString = interestedDateEnd.toISOString();

const {newResult, legacyResult} = await fetchElasticSearchHitsData(project, openshiftProjectName, interestedYearMonth, interestedDateBeginString, interestedDateEndString)
const {newResult, legacyResult} = await fetchElasticSearchHitsData(project.replace('_', '-'), openshiftProjectName, interestedYearMonth, interestedDateBeginString, interestedDateEndString)

if ( newResult === null || legacyResult === null ){
return { total: 0 }
Expand Down

0 comments on commit 2756587

Please sign in to comment.