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

Server-side CSV export for some reports #484

Merged
merged 15 commits into from
Feb 24, 2021
Merged

Server-side CSV export for some reports #484

merged 15 commits into from
Feb 24, 2021

Conversation

jaragunde
Copy link
Member

@jaragunde jaragunde commented Jan 22, 2021

Implement server-side CSV export for the following reports:

  • accumulated hours
  • weekly project hours
  • user tasks

Enhancements to backend code were done if possible.

Implements #475, but there are some reports left.

This is controlled by a newly added GET parameter. Set "format=csv" for
it to output data in CSV format. Any other value for the format
parameter, or not setting it at all, will output the usual expected
JSON data.

We have changed the internal key used to identify the columns from
"$week-$year" to "$year-$week", so the list of columns can be easily
sorted. We also added an index key to $records as a way to sort the
rows. Sorting was not taken into consideration before, because it was
performed by the client side.

CSV export code is inspired by this example:
https://www.virendrachandak.com/techtalk/creating-csv-file-using-php-and-mysql/
Access to the previous CSV exporter was not removed, for users to test
and compare the two implementations.
This report queries two different services. Here, we implement server-
-side CSV export for the extra hours fields.

The CSV export code is inelegantly interspersed in the existing XML
generation code. This service would likely need a complete rewrite to
make things look better.
This report queries two different services. Here, we implement server-
-side CSV export for the pending holiday hours field independently; it
will be output to a different file from the rest of the fields in the
report.

This service would likely require a complete rewrite to make things
better.
We rework and simplify the XML output code a bit, it looks better and
allows us to reuse more for the CSV export.

TODO: additional logic to patch user and project IDs with their names,
because that happens client-side in the web page.
Old CSV exporter is not removed yet, as they have different features
at the moment.
In getTasksFiltered.php we were escaping text fields for XML regardless
of the requested format.
Add a new parameter for the service, "showProjectNames", which is
enabled in CSV exports, which will and add the project name to the
report output.
Add a new parameter for the service, "calculatePendingHolidays",
enabled in CSV exports, which will call the GetPendingHolidayHours
operation and add the data to the report.

TODO: take advantage of this feature to simplify the front-end of this
report, calling to one service instead of two.
@jaragunde jaragunde merged commit 5ae544d into main Feb 24, 2021
@jaragunde jaragunde deleted the new-csv-exporter branch February 24, 2021 09:55
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.

None yet

1 participant