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

feat(analytics): add monthly active users in highlights #7341

Merged
merged 7 commits into from
Feb 20, 2023

Conversation

anshbansal
Copy link
Collaborator

@anshbansal anshbansal commented Feb 14, 2023

image

image

image

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

"Weekly Active Users",
"%.2f%% %s from last week",
endDate,
(date) -> date.minusWeeks(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this a function? It seems more readable to me to just directly put the startDate here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because the lambda is re-used multiple times.

DateTime endDate = DateTime.now();
highlights.add(getTimeBasedHighlight(
"Weekly Active Users",
"%.2f%% %s from last week",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this change string a top level constant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is unique to this chart and won't be reused.


DateTime endDate = DateTime.now();
highlights.add(getTimeBasedHighlight(
"Weekly Active Users",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also make these constants?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is unique to this chart and won't be reused.

@github-actions github-actions bot added the product PR or Issue related to the DataHub UI/UX label Feb 14, 2023
@anshbansal anshbansal marked this pull request as draft February 14, 2023 17:53
@anshbansal
Copy link
Collaborator Author

Marking as draft as some more changes need to be done which will require more testing. Will mark as ready for review once those changes are done.

@anshbansal anshbansal marked this pull request as ready for review February 20, 2023 10:21
@@ -42,39 +42,17 @@ function computeLines(chartData: TimeSeriesChartType, insertBlankPoints: boolean

const startDate = new Date(Number(chartData.dateRange.start));
const endDate = new Date(Number(chartData.dateRange.end));
const intervalMs = INTERVAL_TO_SECONDS[chartData.interval] * 1000;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was causing problem with Months related maths.

final DateInterval interval,
final Function<DateTime, DateTime> convertToBegin
) {
final DateTime beginning = convertToBegin.apply(endDateTime);
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor naming nit. you can call this beginningDateTime to keep consistency

.withMinuteOfHour(0)
.withSecondOfMinute(0)
.withMillisOfDay(0)
));
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice!

Double percentChange =
(Double.valueOf(weeklyActiveUsers) - Double.valueOf(weeklyActiveUsersLastWeek)) / Double.valueOf(
weeklyActiveUsersLastWeek) * 100;
if (activeUsersLastRange > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice refactoring!

const returnLines: NamedLine[] = [];
chartData.lines.forEach((line) => {
const newLine = [...line.data];
for (let i = endDate.getTime(); i > startDate.getTime(); i -= intervalMs) {
for (let i = startDate; i <= endDate; i = addInterval(1, i, chartData.interval)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice use of add interval!

Copy link
Collaborator

@jjoyce0510 jjoyce0510 left a comment

Choose a reason for hiding this comment

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

Overall looks good

@jjoyce0510 jjoyce0510 merged commit 8a1a24b into master Feb 20, 2023
@jjoyce0510 jjoyce0510 deleted the aseem-add-chart-monthly-user branch February 20, 2023 22:17
oleg-ruban pushed a commit to RChygir/datahub that referenced this pull request Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR or Issue related to the DataHub UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants