Updated metrics components for compare mode.

This commit is contained in:
Mike Cao committed 2024-05-23 00:17:20 -07:00
1 parent 6b03935fca
commit df66acaacf
117 files changed
+602 -513

No files matched your search

+3 -1
View File
@@ -22,6 +22,7 @@ export interface WebsiteStatsRequestQuery {
country?: string;
region?: string;
city?: string;
compare?: string;
}
import * as yup from 'yup';
@@ -41,6 +42,7 @@ const schema = {
country: yup.string(),
region: yup.string(),
city: yup.string(),
compare: yup.string(),
}),
};
@@ -77,7 +79,7 @@ export default async (
const stats = Object.keys(metrics[0]).reduce((obj, key) => {
obj[key] = {
value: Number(metrics[0][key]) || 0,
change: Number(metrics[0][key]) - Number(prevPeriod[0][key]) || 0,
prev: Number(prevPeriod[0][key]) || 0,
};
return obj;
}, {});