Skip to content

DatabaseScheduler._get_unique_timezone_names returns multiple of the same results #947

@justmobilize

Description

@justmobilize

While testing the version 2.8.1 to see if it's safe to use (base on #894), I found that with the new code for optimizing loading of schedules, the method DatabaseScheduler._get_unique_timezone_names was added, but without fields, distinct uses all of them. This should be written as:

    def _get_unique_timezone_names(self):
        """Get a list of all unique timezone names used in CrontabSchedule"""
        return CrontabSchedule.objects.values_list(
            'timezone', flat=True
        ).order_by('timezone').distinct('timezone')

NOTE: order_by needed for the distinct to work correctly.

Without the change, that method returns multiple of the same timezones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions