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

Schedule report tasks and add report preview view #1620

Merged
merged 4 commits into from
Feb 10, 2025
Merged

Conversation

GregKaleka
Copy link
Collaborator

@GregKaleka GregKaleka commented Jan 29, 2025

  • Significantly improved the speed of the "Do Everything" (DE) button by restricting the data imports to the most recent two versions (for diffing), when before they were importing everything, taking hours. Should now take less than an hour to complete. Locally, I had it complete in around 15 minutes.
  • Added actual report generation and caching to the DE button (this takes only a few extra seconds)
  • Added a weekly scheduled task that runs the DE process
  • Added a url and view for staff only that shows the cached report for a given version if it exists, available at /releases/<version_slug>/report

Note: I have not implemented PDF rendering. I can do so, but wanted to have some discussion about what library to use. I've used WeasyPrint in the past, and the results have been good, though I recall the dev experience being annoying (someone on the team was always having to install some supporting thing on their machine).

Update: I attempted to get PDF rendering working with weasyprint. The results were close but I could not get some of the styling to work. In agreement with Rob, we're going to move forward with this html-only version for now, since it takes a lot of the manual work out already. We can revisit programmatic PDF rendering in the future.

Fixes #1603

email = person_data.pop("email") or generate_fake_email(
f"{person_data['first_name']} {person_data['last_name']}"
)
if not (user := User.objects.filter(email=email).first()):
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: the brackets here probably aren't needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They are actually needed. You can try it yourself:

>>> if not foo := 0:
  File "<stdin>", line 1
    if not foo := 0:
       ^^^^^^^
SyntaxError: cannot use assignment expressions with expression
>>> if not (foo := 0):
...     print("hello")
... 
hello


return handled_commits


def check_credentials() -> list[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Small thing to think about rather than a blocker. I'm not sure about the naming of this. I think it could be something more intuitive maybe. The first impression from the use later would be that check_credentials would return a bool. Maybe something like list_missing_credentials would be more intuitive?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not set on that name either if you can think of something better.



@method_decorator(staff_member_required, name="get")
class ReportPreviewView(View):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth using the BoostVersionMixin here to have centralized handling of that for consistency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does appear to add two extra queries, but the page is so fast and is a preview for staff only anyway. Probably worth it to keep things a bit DRYer.

Copy link
Collaborator

@daveoconnor daveoconnor left a comment

Choose a reason for hiding this comment

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

A few minor comments, mostly looks good. Approved.

@GregKaleka GregKaleka merged commit d537985 into develop Feb 10, 2025
4 checks passed
@GregKaleka GregKaleka deleted the gk/issue-1603 branch February 10, 2025 16:22
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.

Scheduled task for updated weekly release report preview
2 participants