Re: Replicating complex query with two dense_rank() functions using ORM

2020-11-04 Thread Simon Charette
This is unfortunately not possible to do through the ORM right now due to lack of support for filtering against window expressions[0] Until this ticket is solved you'll have to rely on raw SQL. Cheers, Simon [0] ticket https://code.djangoproject.com/ticket/28333 Le mercredi 4 novembre 2020 à

Re: Replicating complex query with two dense_rank() functions using ORM

2020-11-04 Thread Ramon NHB
Hi, In Django queryset you can query PuzzleAnswer, filter by author (assuming that is the user), order_by('created)' and return the created dates only: values_list('created', flat=True). Then take the len() of that list and check the [0] and [-1] entries for first and last date. The rest is

Replicating complex query with two dense_rank() functions using ORM

2020-11-03 Thread Brad Buran
I have a "puzzle of the day" that users can answer. I track the puzzle of the day using the Puzzle model. I track the answers using the PuzzleAnswer model. I would like to calculate the number of consecutive puzzles a particular user (i.e., the author) gets right in a row. The current SQL I