Closed dorianamouroux closed 2 years ago
This is clearly a bug, thank you for bringing it to our attention @dorianamouroux . I think we should fix instead of just removing ability to sort @ihoru. This is useful feature when it works!
I looked a little bit into it, the simplest way would be to create a duration field and store it, otherwise, you can't make it sortable, because the value has to come from the database.
I tried to use queryset.extra()
and create the duration value in the SQL query, but depends on the database, the function to calculate the duration is different (DATEDIFF(end_date, start_date)
in Mysql, julianday(end_date) - julianday(start_date)
in sqlite).
If we create the duration value when we save the model, it wouldn't work for the existing cron log entries, we can create a management command to migrate those.
I can do it and send a PR if you think that's good
@dorianamouroux I think that's a good idea and could be useful elsewhere. Go ahead with it and I'll review the PR. Thanks!
Hi,
I'm using Django_cron and I want to know what are the longest duration time of my tasks. On the admin panel, I want to sort by duration time and when I do, I got a 500 errors as below :
I'm using Django 1.8
Thank you very much