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

Fix export invoices query object filters #2327

Merged
merged 4 commits into from
Jul 24, 2024

Conversation

ancorcruz
Copy link
Contributor

Roadmap Task

👉 https://getlago.canny.io/feature-requests/p/ability-to-export-data-from-the-user-interface

Description

This change include a number of fixes related to query objects in general, the InvoicesQuery objects filters and how the invoices CSV export service uses the InvoicesQuery;

  • Fixes query objects date parsing capabilities as original implementation was able to parse datetimes and failed with dates.
  • Fix InvoicesQuery filters to ensure it works when keys are strings or symbols using the Filters object.
  • Fix DataExports::CSV::Invoices service to use properly the current InvoicesQuery interface as it was missing some filters that are currently outside of the filters hash (will be fixed in misc: refactor query object to align with new design #2313)

BaseQuery `parse_datetime_filter` fails when a string date
representation is parsed, even when the date format is "%Y-%m-%d".

Given we work with times and dates in iso8601 format... we can use
`DateTime.iso8601` method to parse dates, and date times with no errors.
from the graphQL invoices resolver
from the REST API invoices controller
and from the DataExports services given the filters are saved in a
database fields and keys are converted into strings.

Also, this change fixes the query performed for the CSV export as before
was missing some filters that currently are outside of the filters hash.
@ancorcruz ancorcruz self-assigned this Jul 23, 2024
app/queries/invoices_query.rb Show resolved Hide resolved
app/services/data_exports/csv/invoices.rb Outdated Show resolved Hide resolved
app/services/data_exports/csv/invoices.rb Outdated Show resolved Hide resolved
use single quotes instead of double when no interpolation

Co-authored-by: Ivan Novosad <[email protected]>
@ancorcruz ancorcruz merged commit f6b1f78 into main Jul 24, 2024
6 checks passed
@ancorcruz ancorcruz deleted the fix-export-invoices-query-object-filters branch July 24, 2024 11:01
abdussamadbello pushed a commit to abdussamadbello/lago-api that referenced this pull request Aug 8, 2024
## Roadmap Task

👉
https://getlago.canny.io/feature-requests/p/ability-to-export-data-from-the-user-interface


## Description

This change include a number of fixes related to query objects in
general, the InvoicesQuery objects filters and how the invoices CSV
export service uses the InvoicesQuery;

* Fixes query objects date parsing capabilities as original
implementation was able to parse datetimes and failed with dates.
* Fix InvoicesQuery filters to ensure it works when keys are strings or
symbols using the Filters object.
* Fix DataExports::CSV::Invoices service to use properly the current
InvoicesQuery interface as it was missing some filters that are
currently outside of the filters hash (will be fixed in
getlago#2313)

---------

Co-authored-by: Ivan Novosad <[email protected]>
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