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

Stale Case Data Mail Report #35446

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

zandre-eng
Copy link
Contributor

@zandre-eng zandre-eng commented Nov 26, 2024

Product Description

No user-facing changes. This new report is only sent out via mail and is not included in HQ's UI.

Technical Summary

Link to ticket here.

A new periodic Celery task is created with the responsibility of sending out a email report to the SOLUTIONS_AES_EMAIL email address on a monthly basis. This is a simple report that contains a formatted table listing domains which have open cases that have not been modified in over a year.

The goal of this report is to identify which domains could be potential candidates for auto-update rules to be implemented.

Feature Flag

None

Safety Assurance

Safety story

  • Local testing
  • Unit tests

Automated test coverage

Unit tests exist for the new StaleCasesTable class and test to make sure that it retrieves the correct data and formats it appropriately.

QA Plan

No QA planned.

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

@zandre-eng zandre-eng added the product/invisible Change has no end-user visible impact label Nov 26, 2024
@zandre-eng zandre-eng marked this pull request as ready for review November 26, 2024 12:40
@orangejenny
Copy link
Contributor

Code looks fine, though I only skimmed it. Do you know how many domains currently meet this criteria on prod? I wonder if it would be helpful to filter them, possibly by subscription, to domains that solutions is most likely to take action on.

Copy link
Contributor

@kaapstorm kaapstorm left a comment

Choose a reason for hiding this comment

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

This is nice. Just a couple of suggestions.

)

@property
def rows(self):
Copy link
Contributor

@kaapstorm kaapstorm Nov 29, 2024

Choose a reason for hiding this comment

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

Using table.rows twice will run the query twice. How about something like this?

    def __init__():
        self._rows = None

    @property
    def rows(self):
        if self._rows is None:
            self._rows = []
            # etc.
        return self._rows

Comment on lines +538 to +539
@staticmethod
def format_as_table(row_data, data_tables_header):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a useful function, but it is more generic than this class, and it expects its headers to be a list of DataTablesHeader instances. For those reasons, I would pull it out of here, move it somewhere under corehq/apps/reports/datatables/, and maybe rename it. If you feel that having a method is useful, you could change this to something like:

    def format_as_table(self):
        return datatable_as_text(self.rows, self.headers)

(Obviously assumes that self.rows doesn't run the query again.)

(Not applicable here because it's probably not worth an additional requirement, but useful to know about: Tablib is cool, and it can do this. (Also, I'm biased, because I wrote that bit.))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/invisible Change has no end-user visible impact
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants