UI/cleanup client charts for 1.11 (#15408)

* remove manipulations of data ranges;

* fix bar aligntment

* consume empty months existing on response

* revert grey bar transformation

* up one more line..

* remove attr
This commit is contained in:
claire bontempo
2022-05-18 16:47:16 -07:00
committed by GitHub
parent c1fc8530d6
commit 07f39fd269
3 changed files with 8 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ import { parseAPITimestamp } from 'core/utils/date-formatters';
import { compareAsc } from 'date-fns';
export const formatByMonths = (monthsArray) => {
// the months array will always include a timestamp of the month and either new/total client data or counts = null
if (!Array.isArray(monthsArray)) return monthsArray;
const sortedPayload = sortMonthsByTimestamp(monthsArray);
return sortedPayload.map((m) => {
@@ -14,7 +15,7 @@ export const formatByMonths = (monthsArray) => {
return {
month,
...totalCounts,
namespaces: formatByNamespace(m.namespaces),
namespaces: formatByNamespace(m.namespaces) || [],
namespaces_by_key: namespaceArrayToObject(totalClientsByNamespace, newClientsByNamespace, month),
new_clients: {
month,
@@ -75,7 +76,6 @@ export const homogenizeClientNaming = (object) => {
};
export const flattenDataset = (object) => {
// TODO CMB revisit when backend has finished ticket VAULT-6035
if (object?.counts) {
let flattenedObject = {};
Object.keys(object['counts']).forEach((key) => (flattenedObject[key] = object['counts'][key]));
@@ -94,6 +94,7 @@ export const sortMonthsByTimestamp = (monthsArray) => {
};
export const namespaceArrayToObject = (totalClientsByNamespace, newClientsByNamespace, month) => {
if (!totalClientsByNamespace) return {}; // return if no data for that month
// all 'new_client' data resides within a separate key of each month (see data structure below)
// FIRST: iterate and nest respective 'new_clients' data within each namespace and mount object
// note: this is happening within the month object