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

UI/Client count running totals component #14967

Merged
merged 10 commits into from
Apr 12, 2022

Conversation

hellobontempo
Copy link
Contributor

@hellobontempo hellobontempo commented Apr 7, 2022

PR to add the Running total component to the client count history tab

Screen Shot 2022-04-08 at 10 46 10 AM

@@ -34,20 +34,22 @@ export default class ActivitySerializer extends ApplicationSerializer {

// for vault usage - vertical bar chart
flattenByMonths(payload, isNewClients = false) {
const sortedPayload = [...payload];
sortedPayload.reverse();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially created a method to sort months by date - but this requires iterating through and converting the timestamp to a date object, comparing each and then formatting the timestamp into the M/yy format.

The API always returns a chronological array of months in order from most recent to oldest. So to save computing this in the frontend opted to just reverse this order.

// TODO CMB make these two functions utils?

// format ISO timestamp to M/yy
formatTimestamp(timestamp) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timestamp looks like: 2021-03-21T00:00:00Z - if you directly format this, it returns a date object associated with the user's relative timezone. We want to globally return the same year and month as the API, so by splitting on T and parsing after we consistently get 3/21

@@ -2,6 +2,7 @@ import Route from '@ember/routing/route';
import { isSameMonth } from 'date-fns';
import RSVP from 'rsvp';
import getStorage from 'vault/lib/token-storage';
import { parseRFC3339 } from '../../../../utils/date-formatters';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than moving up the tree you could use the vault alias for this import:
import { parseRFC3339 } from 'vault/utils/date-formatters';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes - thank you! It auto-imported like this and I didn't even think to clean it up!

Comment on lines -91 to -97
parseRFC3339(timestamp) {
// convert '2021-03-21T00:00:00Z' --> ['2021', 2] (e.g. 2021 March, month is zero indexed)
return timestamp
? [timestamp.split('-')[0], Number(timestamp.split('-')[1].replace(/^0+/, '')) - 1]
: null;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice moving this to a util!

@vercel vercel bot temporarily deployed to Preview – vault April 8, 2022 22:59 Inactive
@@ -196,7 +196,7 @@ module('Acceptance | clients history tab', function (hooks) {
assert.dom('[data-test-stat-text="total-clients"] .stat-value').hasText('15');
assert.dom('[data-test-stat-text="entity-clients"] .stat-value').hasText('5');
assert.dom('[data-test-stat-text="non-entity-clients"] .stat-value').hasText('10');
await waitUntil(() => find('[data-test-horizontal-bar-chart]'));
await settled();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitUntil kept timing out so going to try removing it..

Copy link
Contributor

@zofskeez zofskeez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool thanks for this!

@hellobontempo hellobontempo merged commit 17747dc into main Apr 12, 2022
@hellobontempo hellobontempo deleted the ui/clients-running-totals-component branch April 12, 2022 18:31
kitography pushed a commit that referenced this pull request Apr 24, 2022
* wire up running total component

* remove waitUntil

* remove unused functions

* abstract x/y keys

* adjust tick size

* refactor helpers into utils

* cleanup

* cleanup utils files and imports

* update variables to const

* mock empty monthly data
schultz-is pushed a commit that referenced this pull request Apr 27, 2022
* wire up running total component

* remove waitUntil

* remove unused functions

* abstract x/y keys

* adjust tick size

* refactor helpers into utils

* cleanup

* cleanup utils files and imports

* update variables to const

* mock empty monthly data
schultz-is pushed a commit that referenced this pull request May 2, 2022
* wire up running total component

* remove waitUntil

* remove unused functions

* abstract x/y keys

* adjust tick size

* refactor helpers into utils

* cleanup

* cleanup utils files and imports

* update variables to const

* mock empty monthly data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants