Skip to content

Instantly share code, notes, and snippets.

@andrelip
Created July 10, 2017 16:35
Show Gist options
  • Select an option

  • Save andrelip/1b9275df8daebc69c2fd97752a07a7fa to your computer and use it in GitHub Desktop.

Select an option

Save andrelip/1b9275df8daebc69c2fd97752a07a7fa to your computer and use it in GitHub Desktop.
def get_list do
from(p in Pages,
join: v in ViewedBook,
join: r in Reader,
where: p.viewed_book_id == v.id and v.profile_id == r.id,
where: p.time_spent > 5,
group_by: r.id,
select: %{reader_id: r.id, entity_id: r.entity_id, root_id: r.root_id, time_spent: sum(p.time_spent)})
|> Repo.all
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment