-
Notifications
You must be signed in to change notification settings - Fork 7
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
Separate incident targets into journalists and institutions #776
Conversation
b7be61f
to
c641eb3
Compare
This one fell out of sync with master, which is blocking deploys to sandbox given lack of logic from #780. @harrislapiroff if you can rebase this in lieu of @chigby as part of review, we can get you a sandbox deploy to aid in review, if that's helpful. |
9f69acb
to
efcea7e
Compare
Rebased on top of latest master (05befcf) 😇 |
efcea7e
to
8a2fb04
Compare
320d88c
to
19fd40c
Compare
fd9081f
to
f8b2118
Compare
292d77c
to
7dc29de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed the code and checked it in my local. It seems to do what it is supposed to do based on the description. I am just a little picky about too many merge migrations. I mean I know that the PR has been out there for a pretty long time and hence merge migrations, so it is not a blocker according to me for getting the PR merged. Also, @harrislapiroff might want to give a second check on the UX and implementation. But I checked and it works.
e080e68
to
70ac60e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great. I think this is absolutely the right approach. Going to test it now.
@@ -50,7 +50,7 @@ class FiltersList extends PureComponent { | |||
</ul> | |||
) | |||
} else { | |||
renderedValue = filterValues[filter.name].label | |||
renderedValue = filterValues[filter.name].title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
Targeted Journalists | ||
</th> | ||
<td class="data-table__value"> | ||
{% with page.targeted_journalists.all as journalists%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a space
{% with page.targeted_journalists.all as journalists%} | |
{% with page.targeted_journalists.all as journalists %} |
summary = ( | ||
('Total Results', total_queryset.count()), | ||
('Journalists affected', Target.objects.filter(targets_incidents__in=total_queryset).distinct().count()), | ||
('Journalists affected', Journalist.objects.filter(targeted_incidents__in=tj_queryset).distinct().count()), | ||
('Institutions affected', Institution.objects.filter(institutions_incidents__in=total_queryset).distinct().count()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should read "Organizations affected" instead or something. Will check with @KAMcCudden
One thing that worries me is that if we're not careful, we're going to silently lose targets that don't have a "Kind" set. I noticed in my local testing, targets that were uncategorized weren't migrated at all. I'm not sure what a good solution to this would be. Having the migration throw and error if there are unmarked targets in the db? Writing a management command to migrate unmigrated targets? Just making absolutely sure all targets are marked before we deploy? Since this PR leaves the data in place I'm not necessarily considering this a blocker, but I'd like a good idea for how we plan to address this before we merge it. Accepting suggestions |
I will make sure the DB is up to date from my perspective this week (give me deadline if need sooner) and then there are all the leak case targets, where the target is neither an org nor a journalist. those have intentionally been left blank |
Oooooh we might need a third category for them then 😬 The notion here is to make a clean separation of different target types in the database (such that we can accurately calculate, e.g., "Number of journalist subpoenas" vs "Number of organization subpoenas") and eventually get rid of the "Target" data type altogether... We could create a new data type for those called "Non-journalist targets"? Would that make sense as a category @KAMcCudden? Something more specific? |
I actually think a third category is good. As in, if our concept of a target has three different varieties that need to be treated/counted differently, our database layout should express that. We don't even necessarily need to remove the "Target" table, we could move journalists and institutions out of it (as done in this PR) and leave the rest of the contents there as the data referred to by leak case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After chatting with @chigby and @KAMcCudden, we've agreed that we need a third data type for non-journalist targets (potentially GovernmentEmployee
). Since @KAMcCudden has been leaving these unmarked in the database (there's 8 of them, currently), let's migrate all unmarked targets to that object type.
74db844
to
9533e25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change and I still have to do some more local testing. This is looking good though, otherwise!
<li class="data-table__list-item"> | ||
<a href="{% pageurl page.get_parent %}?targets={{ target.pk }}">{{ target.title }}</a> | ||
<a href="{% pageurl page.get_parent %}?workers_whose_communications_were_obtained={{ target.pk }}">{{ target.title }}</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good catch on this behavior. I agree that the old behavior was likely unintended.
@@ -68,7 +68,7 @@ <h2 class="sr-only section-heading">Incident Data</h2> | |||
Targeted Journalists | |||
</th> | |||
<td class="data-table__value"> | |||
{% with page.targeted_journalists.all as journalists%} | |||
{% with page.targeted_journalists.all as journalists %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨
] | ||
|
||
operations = [ | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol we're really gonna wanna squash migrations when we're done here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Ready to merge as soon as @chigby prepares a deployment plan.
Also add a migration to copy data from the old field to the new fields.
The `targeted_institutions` field was only a `ManyToMany` field to accomodate a data migration, we actually want it to be a `ParentalManyToMany`. See discussion for more information: #707 (comment)
This was something that seems to have slipped through the cracks when we upgraded to the latest "official" version of the autocomplete plugin. It seems fine to hard-code the locations of the css and js files, given that we don't really expect them to change anytime soon.
We're pretty sure it's easy enough to add journalists to the site that we're going to want some mechanism for combining erroneously added ones, i.e. the times when an editor adds a journalist when they intended to reference an existing one.
This is required due to rebasing on top of the wagtail 2.0 upgrade code.
These tests were added in master, which we've now rebased on, so let's make them work for us.
This I think is needed because the choices for the incident filters and statistics items are dynmically generated, and we've altered the potential options for them by adding the journalists/institution fields, so these need to be updated to take that into account.
This new model is intended to be a classification of targets whose communications were obtained during leak investigations. A data migration has been added to copy all data from `IncidentPage.targets_whose_communications_were_obtained` into this new model. The target data is not deleted. I've also added the usual "Incident M2Ms" items for managing and merging government workers.
In leak cases, we now show the new, more specific classification Government Worker instead of the old Target information. It actually looks like there's a change in behavior here (possibly fixing something unintended) where the link on a target's name now goes to the search page with the filter for other incidents in which that target's comms were obtained. Before, it linked to the filter of all incidents *targeting* this person *generally*, which is not the same thing under our schema. The new behavior seems more correct to me, as the linked-to filter is now the same context as the link.
513ec67
to
7b06c47
Compare
Going to merge this, but I would like to coordinate the deploy for this feature a little more carefully, which maybe means holding off on the next release till Monday. |
This pull request:
IncidentPage.targets
withInstitution
andJournalist
objects.TargetedJournalist
relating a journalist to an incident as well as an institution (representing which institution they were with at the time of the incident, if any).Target
table into theJournalist
andInstitution
tables as appropriate. Due to a bug in themodelcluster
package, this must be done prior to converting theIncident.targeted_institutions
relationship to aParentalManyToManyField
, so there are is a secondary migration file to do that conversion after the data migration is done.get_summary
method on incidents to report counts of both journalists affected and institutions affected (instead of just targets).Notably, this pull request does not remove the
Target
model or its relationship toIncidentPage
, only places where that data is displayed publically. I feel that when this pull request is live and working, only then should we feel confident enough to remove the old tables and code.Note that in order for the new fields to be filterable on the production site, as it stands now, the incident filter settings will have to be manually changed from filtering by targets to filtering by institutions and journalists.
Also notable: this PR doesn't touch the relationshipIncidentPage.targets_whose_communications_were_obtained
Addenda 2020-02-12:
Adds another category to replace items in the
Targets
table with a blankkind
field:GovernmentWorker
. It functions likeInstitution
above in that its relationship toIncidentPage
is many-to-many without a through model. I've added a relationship toIncidentPage
namedworkers_whose_communications_were_obtained
and a data migration to copy items fromtargets_whose_communications_were_obtained
into this new scheme.The old
targets_whose...
relationship is left intact. It should be removed when we removeTarget
and its relationships, as mentioned above.Added human-readable "stringify" values for
Journalist
andInstitution
(andGovernmentWorker
).Refs #707