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 inddex reports #35605

Merged
merged 4 commits into from
Jan 10, 2025
Merged

Fix inddex reports #35605

merged 4 commits into from
Jan 10, 2025

Conversation

orangejenny
Copy link
Contributor

Product Description

Followup for #35586, which caused these reports to 500.

Technical Summary

The 500 resulted from the data discussed here not being JSON serializable.

The bulk of the inddex js is the same logic that's in tabular.js, with the major difference being that some of the inddex reports have multiple datatables. The general change here is to update the inddex code to rely more on tabular.js.

This PR assumes that all of the inddex tables in a single report have the same datatables options, which from looking at the reports in python I believe is true. The different reports have different slugs & titles, but I didn't see any different display options.

Feature Flag

inddex reports

Safety Assurance

I've tested on staging that the reports now load, and it appears to behave the same as a browser window of the reports on prod that I've had open since before the deploy of #35586.

While working on this I realized that I could have tested the previous PR on staging. I had initially hit errors there, eventually rebuilt the underlying table, and was still running into errors. But I think I just didn't wait long enough after rebuilding.

Safety story

There are minor changes to tabular.js, but most of the work is in custom code.

As in #35586, the impact of problems here is limited. The only live projects using them are on a third party env, so the changes won't be "live" for real users until that env deploys.

Automated test coverage

Not at the UI level.

QA Plan

Not requesting QA

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

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

@orangejenny orangejenny added the product/custom Change will only impact users on a single project label Jan 9, 2025
@@ -15,12 +15,22 @@ class MultiTabularReport(DatespanMixin, CustomProjectReport, GenericTabularRepor
exportable = True
exportable_all = True
export_only = False
fix_left_col = True
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This and fixed_cols_spec below are to support the fixColumns, fixColsNumLeft, and fixColsWidth values that were previously specified directly in the inddex js.

@@ -34,10 +44,11 @@ def _to_context_dict(data_provider):
'rows': list(data_provider.rows),
}

context = {
context = super().report_context
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This pulls in the report_table_js_options specified here. This is where the assumption is made that all of the tables in a single inddex report will have the same js options - I'm not pulling them separately for each data_provider.

@@ -68,6 +68,9 @@ hqDefine("reports/js/bootstrap5/tabular", [

// Handle async reports
$(document).on('ajaxSuccess', function (e, xhr, ajaxOptions, data) {
if (!data || !data.slug) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because inddex/main is now importing this file, it gets this event handler, which it doesn't need, and which errors sometimes (presumably because there are ajax requests happening that aren't the same as what this handler expects). But checking for data.slug is pretty innocuous and fixes the issue.

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 think it would be cleaner to put the event handlers in an init function, and make code that imports this module explicitly call it, but I wanted to limit changes to core reports as much as possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of putting this comment in the code? This seems far away from inddex/main, and it might be nice to know why this check was added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure - 715c441

@@ -68,6 +68,9 @@ hqDefine("reports/js/bootstrap5/tabular", [

// Handle async reports
$(document).on('ajaxSuccess', function (e, xhr, ajaxOptions, data) {
if (!data || !data.slug) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of putting this comment in the code? This seems far away from inddex/main, and it might be nice to know why this check was added.

@orangejenny orangejenny merged commit 64ca8e2 into master Jan 10, 2025
12 of 13 checks passed
@orangejenny orangejenny deleted the jls/inddex-front-to-back branch January 10, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/custom Change will only impact users on a single project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants