mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: TUVote inner join TUVoteInfo for "Last Votes by TU" listing
By implicitly joining, sqlalchemy joined on `TUVote.UsersID = TUVoteInfo.SubmitterID`. This should be joining on `TUVote.VoteID = TUVoteInfo.ID` instead to include all TUVote instances found in the database. Closes #266 Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
957803a70b
commit
660d57340a
2 changed files with 28 additions and 12 deletions
|
@ -81,17 +81,18 @@ async def trusted_user(request: Request,
|
|||
context["past_off"] = past_off
|
||||
|
||||
last_vote = func.max(models.TUVote.VoteID).label("LastVote")
|
||||
last_votes_by_tu = db.query(models.TUVote).join(
|
||||
models.User
|
||||
).join(models.TUVoteInfo).filter(
|
||||
last_votes_by_tu = db.query(models.TUVote).join(models.User).join(
|
||||
models.TUVoteInfo,
|
||||
models.TUVoteInfo.ID == models.TUVote.VoteID
|
||||
).filter(
|
||||
and_(models.TUVote.VoteID == models.TUVoteInfo.ID,
|
||||
models.User.ID == models.TUVote.UserID,
|
||||
models.TUVoteInfo.End <= ts,
|
||||
models.TUVoteInfo.End < ts,
|
||||
or_(models.User.AccountTypeID == 2,
|
||||
models.User.AccountTypeID == 4))
|
||||
).with_entities(
|
||||
models.TUVote.UserID,
|
||||
func.max(models.TUVote.VoteID).label("LastVote"),
|
||||
last_vote,
|
||||
models.User.Username
|
||||
).group_by(models.TUVote.UserID).order_by(
|
||||
last_vote.desc(), models.User.Username.asc())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue