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

Homepage showing more than 6 streams #655

Open
clone1018 opened this issue Apr 23, 2021 · 3 comments
Open

Homepage showing more than 6 streams #655

clone1018 opened this issue Apr 23, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@clone1018
Copy link
Member

Shouldn't technically be possible, but it looks like we have a misconfigured query somewhere...

image

Database State:

id channel_id slot_started_at slot_ended_at
1902 10552 2021-04-23 13:53:54 2021-04-23 14:53:54
1901 5600 2021-04-23 13:53:54 2021-04-23 14:53:54
1900 7538 2021-04-23 13:53:54 2021-04-23 14:53:54
1899 12937 2021-04-23 13:53:54 2021-04-23 14:53:54
1898 13204 2021-04-23 13:53:54 2021-04-23 14:53:54
1897 503 2021-04-23 13:53:54 2021-04-23 14:53:54
1896 7538 2021-04-23 13:53:54 2021-04-23 14:53:54
1895 13204 2021-04-23 13:53:54 2021-04-23 14:53:54
1894 503 2021-04-23 13:53:54 2021-04-23 14:53:54
1893 5600 2021-04-23 13:53:54 2021-04-23 14:53:54
1892 10552 2021-04-23 13:53:54 2021-04-23 14:53:54
1891 14586 2021-04-23 13:53:54 2021-04-23 14:53:54
@clone1018 clone1018 added the bug Something isn't working label Apr 23, 2021
@clone1018
Copy link
Member Author

Oops, I think there should be a group_by here:

Repo.all(
from c in Channel,
as: :channel,
join: s in assoc(c, :streams),
on: c.stream_id == s.id,
join: u in assoc(c, :user),
on: c.user_id == u.id,
where:
c.status == "live" and
c.show_on_homepage and
s.started_at <= ^fifteen_minutes_ago and
is_nil(s.ended_at) and
c.id in subquery(ten_hour_query),
limit: 6,
order_by: fragment("RANDOM()")
)
end

@clone1018 clone1018 self-assigned this Apr 25, 2021
@clone1018
Copy link
Member Author

Looking into this more, it's not reproducible in development. It's likely the homepage generator script is either being run by two nodes, or the same node is running it twice!

@clone1018 clone1018 removed their assignment Apr 25, 2021
@Eein
Copy link
Contributor

Eein commented Jun 2, 2021

worst case you can cap limit 6 after the query to chop off the end :) that would be the easiest fix as long as there isn't a major performance cost to doing a Repo.all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants