Onboarding backfill#2750
Conversation
Current coverage is
|
|
local migration didn't work as I think I messed up my database state. |
| ) | ||
|
|
||
| projects = Project.objects.filter(organization=org).exclude(first_event=None).order_by('first_event') | ||
| project_count = projects.count() |
There was a problem hiding this comment.
This is relatively expensive if there were a large number of projects.
Really what you're asking for here is "are there 0, 1, or 1+" projects. You don't care about the exact count.
In that case, you should add a LIMIT clause in here with [0:2]. This will apply LIMIT 2. Now you can continue the same comparison with a much cheaper COUNT query.
There was a problem hiding this comment.
Oh, I see, you need to ultimately iterate over all the projects anyways later. So now this is being done in two queries. There's no reason to query for COUNT, when we can just evaluate the queryset and get the len() of the list.
from sentry.plugins import plugins
from sentry.plugins import IssueTrackingPlugin, NotificationPlugin
notification_keys = []
issue_keys = []
for p in plugins.all(version=1):
if isinstance(p, NotificationPlugin):
notification_keys.append(p._get_option_key('enabled'))
elif isinstance(p, IssueTrackingPlugin):
issue_keys.append(p._get_option_key('enabled'))This will give you all the keys you need for checking against, rather than hardcoding a list. |
organization on-boarding data backfill
No description provided.