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

Simplify the query #8076

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Simplify the query #8076

wants to merge 1 commit into from

Conversation

jwjwyoung
Copy link

No description provided.

@jhass
Copy link
Member

jhass commented Dec 3, 2019

Looks like there's some edge cases/historic crufty databases where that can happen:

30af2e7

As for the username, if I remember correctly at some point our invite system would create blank user records and that's why it's there. The initial version of this has the filter: c98f2d1 So I cannot find a documented reasoning.

In any case the difference seems small, the database has to do a sequential scan over the table for either case.

Copy link
Member

@tclaus tclaus left a comment

Choose a reason for hiding this comment

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

A small improvement. Might be more reworked in future, user per week might be calculated by a group statement.
But this change is OK.

@SuperTux88
Copy link
Member

The username shouldn't be a problem, I cleaned up old invitations in #6976, and the column is NOT NULL now.

But I'm not sure about created_at. It wasn't always NOT NULL, and it looks like the NOT NULL was silently added in 28a71a4 without ever having a proper migration which would add it on pods which don't have it yet.

So there might still be pods where there are users without a created_at. At least joindiaspora has users without created_at, but maybe that's a JD-only thing again. All other pods I have access to don't have users without created_at (but they also already have the NOT NULL, as they were created after that, or migrated to postgres after that commit), and I asked DenSchub about geraspora (to check another pretty old pod), and there are also no users without a created_at.

With the current code, if created_at is NULL, it crashes in the line week = u.created_at.beginning_of_week.strftime("%Y-%m-%d") where it tries to access that.

So I'm unsure about that. I feel like we need a proper migration first, which ensures that all (old) pods have all the columns with NOT NULL where it was silently added in 28a71a4, only then we can be sure that it's really NOT NULL as expected everywhere.

(It doesn't need to be changed in this PR, I think this PR is fine as it is ... but I think it should be changed before this is merged, because otherwise we maybe risk breaking some pods)

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

4 participants