Created
April 17, 2017 01:24
-
-
Save joshrendek/0212d911726ffc10a84612e31119a0df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
** (SyntaxError) web/controllers/streamer_controller.ex:11: unexpected comma. Parentheses are required to solve ambiguity in nested calls. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query = from s in Streamer, | |
join: sb in Subscriber, | |
where: s.id == sb.streamer_id, | |
select: s.name as name, s.id as id, count(sb.id) as subs, | |
group: s.name, s.id, | |
order: subs desc, | |
limit: 100 | |
#preload: [:subscribers] | |
streamers = Repo.all(query) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rows, err := app.DB.Table("streamers").Select( | |
"streamers.id as id, streamers.name as name, count(subscribers.id) as subs", | |
).Joins( | |
"left join subscribers on streamers.id = subscribers.streamer_id", | |
).Group( | |
"streamers.name, streamers.id", | |
).Order("subs desc").Limit(100).Rows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment