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

Add Date Range filtering to Dashboard #503

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

pxwxnvermx
Copy link
Contributor

@pxwxnvermx pxwxnvermx commented Feb 26, 2025

Product Description

This PR removes the year and month filters and adds support for filtering using custom date ranges.

image image

Technical Summary

Ticket Link

This PR also adds refactors for the way grouping in queryset works.

Safety Assurance

Safety story

  • Tested on staging

Automated test coverage

  • Added test to cover the new changes.

Labels & Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@pxwxnvermx pxwxnvermx self-assigned this Feb 27, 2025
@pxwxnvermx pxwxnvermx marked this pull request as ready for review February 27, 2025 12:00
@pxwxnvermx pxwxnvermx force-pushed the pkv/add-date-filtering branch from 7020f53 to c3fcb07 Compare March 3, 2025 14:54
@pxwxnvermx
Copy link
Contributor Author

@calellowitz @sravfeyn bumping for review.

flw_amount_paid = sum(sum_total_users.values())
avg_top_paid_flws = sum(sorted(sum_total_users.values(), reverse=True)[:top_five_percent_len])
visit_data_dict[group_key].update({"flw_amount_paid": flw_amount_paid, "avg_top_paid_flws": avg_top_paid_flws})
return list(visit_data_dict.values())
Copy link
Member

@sravfeyn sravfeyn Mar 5, 2025

Choose a reason for hiding this comment

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

This method is getting quite longer, it becomes difficult to read/modify latter. It will add value to refactor it into a sort of class with separate methods for various colulms/queries.

For e.g.

class VisitDataHelper:

def get_data(**filters):

def get_filter_kwargs()

def get_payment_data()

def get_visit_data()

Not exactly like that, but whatever to break it into smaller pieces will improve readability and testability

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 will try to address this in a future PR.

import monthSelectPlugin from 'flatpickr/dist/esm/plugins/monthSelect';
import 'flatpickr/dist/flatpickr.css';
import 'flatpickr/dist/plugins/monthSelect/style.css';
window.monthPickr = (id, flatPickrConfig = {}, monthPluginConfig = {}) =>
Copy link
Member

@sravfeyn sravfeyn Mar 5, 2025

Choose a reason for hiding this comment

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

Have you tried altering the default style to look more similar to our site? Font-colors, type etc.

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 have not tried updating the colors, since we are going to change the UI soon in the UI refactor.

end_date = make_aware(datetime(year, month or 12, month_end))
from_date = from_date or now().date()
to_date = to_date if to_date and to_date <= now().date() else now().date()
timeseries = get_month_series(from_date, to_date)
Copy link
Member

Choose a reason for hiding this comment

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

timeseries is just months, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is a list of month-year combinations between the from and to dates.

@pxwxnvermx pxwxnvermx requested a review from sravfeyn March 5, 2025 12:22
Add AVG and MAX time to payment metrics filter by payment date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants