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

Date Filtering if date_field is Today #101

Open
Parthian opened this issue Jan 17, 2024 · 0 comments
Open

Date Filtering if date_field is Today #101

Parthian opened this issue Jan 17, 2024 · 0 comments

Comments

@Parthian
Copy link

I have the following date field:
date_recorded = models.DateField(_('Date Recorded'), default=datetime.date.today)

When the model is saved and a report generated any row created 'today' is included in the Pie Chart and the Table but has 0 entries. A hunch suggested setting the 'To Date' filter to the next day. The Pie Chart then went from 0% to 8% with my data and the table row went from 0 to 1.

My guess is a Less Than/ Greater Than should be <= or >= to be inclusive of todays date.

With code like this:
class TypeComputationField(ComputationField):
calculation_method = Count
calculation_field = "type"
verbose_name = _("Category")
name = "type_count"

class SafetyObservationTypeReport(ReportView):
report_model = SafetyObservation
report_title = _("Safety Observation Category Report")
date_field = 'date_recorded'
#limit_records = 10 # Top 10
group_by = "type" # group by choicefield type
columns = [ 'type', (TypeComputationField, {"verbose_name": _("Observations per Category")}) ]
chart_settings = [
Chart(
_("Top 10 Safety Observation Categories"),
Chart.PIE,
data_source=["type_count"],
title_source=["type"]
),
]

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

No branches or pull requests

1 participant