Skip to content

Conversation

dcramer
Copy link
Member

@dcramer dcramer commented Mar 21, 2018

  • Refactors various fixtures to be more dynamic/flexible
  • Removes commits endpoint
  • Only identifies commits from repos with any releases

@dcramer dcramer force-pushed the fix/my-commits-unreleased branch from 9639a03 to 0ace987 Compare March 21, 2018 17:43
@dcramer
Copy link
Member Author

dcramer commented Mar 21, 2018

screen shot 2018-03-21 at 10 43 07 am

@dcramer dcramer requested a review from mattrobenolt March 21, 2018 17:43
@dcramer dcramer force-pushed the fix/my-commits-unreleased branch from 0ace987 to 5e72130 Compare March 21, 2018 17:44
@dcramer
Copy link
Member Author

dcramer commented Mar 21, 2018

EXPLAIN (ANALYZE, BUFFERS) select c1.*
from sentry_commit c1
join (
    select max(c2.date_added) as date_added, c2.repository_id
    from sentry_commit as c2
    join (
        select distinct commit_id from sentry_releasecommit
        where organization_id = 1
    ) as rc2
    on c2.id = rc2.commit_id
    group by c2.repository_id
) as cmax
on c1.repository_id = cmax.repository_id
where c1.date_added > cmax.date_added
and c1.author_id IN (
    select id
    from sentry_commitauthor
    where organization_id = 1
    and lower(email) IN ('dcramer@gmail.com', 'david@sentry.io')
)
order by c1.date_added desc

@dcramer
Copy link
Member Author

dcramer commented Mar 21, 2018

follow up will be to write a cache for "Latest Released Commit" to avoid this query:

    select max(c2.date_added) as date_added, c2.repository_id
    from sentry_commit as c2
    join (
        select distinct commit_id from sentry_releasecommit
        where organization_id = 1
    ) as rc2
    on c2.id = rc2.commit_id
    group by c2.repository_id

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be worth noting that Django's default behavior of iexists and friends is to use UPPER() instead of lower() so if we wanted to add a functional index to this column, which I think we should, we'd likely do it over upper(email) so that Django's stuff works correctly.

@dcramer
Copy link
Member Author

dcramer commented Mar 21, 2018

three options

  • add latest_release_id to Environment?
  • join Environment + Release + ReleaseCommit to select max(date_added) on commit? [ might still be too slow ]
  • add latest_released_commit_id to Environment (ugh)
  • Join Environment + Commit to select date_added
  • Add new model which is like LatestCommit(repository_id, environment_id, commit_id)

I'm leaning towards 3 just to contain/keep it simple

@dcramer dcramer force-pushed the fix/my-commits-unreleased branch 2 times, most recently from 66d86b9 to de2867b Compare March 21, 2018 18:02
- Refactors various fixtures to be more dynamic/flexible
- Removes commits endpoint
- Only identifies commits from repos with *any* releases
@dcramer dcramer force-pushed the fix/my-commits-unreleased branch from de2867b to 3f2b11f Compare March 21, 2018 18:15
@dcramer dcramer merged commit 70caea7 into master Mar 21, 2018
@dcramer dcramer deleted the fix/my-commits-unreleased branch March 21, 2018 18:40
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants