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

[Surrey] CSV export includes subscribers to the report #5006

Open
wants to merge 3 commits into
base: surrey-cobrand
Choose a base branch
from

Conversation

MorayMySoc
Copy link
Contributor

@MorayMySoc MorayMySoc commented Jun 12, 2024

Adds a column, "Subscribers" which uses the problem alert method to populate the number for subscribers.

The original reporter is not automatically subscribed to their own report for Surrey so the figure is those that have subscribed after the report has been created.

Also adds initial test file

https://github.com/mysociety/societyworks/issues/4369

[skip changelog]

Adds a column, "Subscribers" which uses the problem alert
method to populate the number for subscribers.

The original reporter is not automatically subscribed to their
own report for Surrey so the figure is those that have
subscribed after the report has been created.

mysociety/societyworks#4369
@MorayMySoc MorayMySoc requested a review from davea June 12, 2024 15:43
Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 78.26087% with 5 lines in your changes missing coverage. Please review.

Project coverage is 82.60%. Comparing base (92861d1) to head (4a16261).
Report is 7 commits behind head on surrey-cobrand.

Files Patch % Lines
perllib/FixMyStreet/Cobrand/Surrey.pm 61.53% 5 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           surrey-cobrand    #5006      +/-   ##
==================================================
+ Coverage           82.56%   82.60%   +0.03%     
==================================================
  Files                 392      392              
  Lines               30508    30558      +50     
  Branches             4815     4832      +17     
==================================================
+ Hits                25190    25242      +52     
+ Misses               3882     3881       -1     
+ Partials             1436     1435       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

my $report = shift;

return {
alerts => $report->alerts || '0',
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned on Slack this should use Admin::Reports::alerts_for_report to get the same value as displayed in the admin report edit page.

Copy link
Member

Choose a reason for hiding this comment

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

Just to add note from Slack discussion - this cannot use that either, because that would still be a per-row database lookup, and we can't have any per-row database lookups in this code.

@davea davea self-requested a review June 26, 2024 09:09
Copy link
Member

@davea davea 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 going in the right direction, but there's a bit more to be done as currently the all-csv-export script is broken by this change.

You'll need to add the SQL to do the lookup to CSVExport.pm and do a $csv->dbi check in Surrey::dashboard_export_problems_add_columns. If you look at $EXTRAS in CSVExport.pm that has a few examples of how this preprocessing is done for other columns.

my @results = FixMyStreet::DB->resultset('Alert')->search({
alert_type => 'new_updates',
confirmed => 1,
cobrand => $self->moniker,
Copy link
Member

Choose a reason for hiding this comment

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

This criteria means any alerts created on fixmystreet.com won't be included in the CSV count (but will be in the value shown on report admin page) - is that intentional?

@MorayMySoc MorayMySoc requested a review from davea July 1, 2024 17:48
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

3 participants