コード例 #1
0
ファイル: lookup.py プロジェクト: WhitespaceCrew/django-htk
def get_users_currently_at_local_time(start_hour, end_hour, isoweekdays=None, active=True):
    """Returns a Queryset of Users whose current local time is within a time range

    `start_hour` and `end_hour` are naive datetimes
    If `isoweekdays` is specified, also checks that it falls on one of the days of the week (Monday = 1, Sunday = 7)
    """
    timezones = get_timezones_within_current_local_time_bounds(start_hour, end_hour, isoweekdays=isoweekdays)
    UserModel = get_user_model()
    users = _filters.users_currently_at_local_time(
        UserModel.objects,
        start_hour,
        end_hour,
        isoweekdays=isoweekdays
    )

    if active is not None:
        users = _filters.active_users(users, active=active)
    return users
コード例 #2
0
def get_users_currently_at_local_time(start_hour, end_hour, isoweekdays=None, active=True):
    """Returns a Queryset of Users whose current local time is within a time range

    `start_hour` and `end_hour` are naive datetimes
    If `isoweekdays` is specified, also checks that it falls on one of the days of the week (Monday = 1, Sunday = 7)
    """
    timezones = get_timezones_within_current_local_time_bounds(start_hour, end_hour, isoweekdays=isoweekdays)
    UserModel = get_user_model()
    users = _filters.users_currently_at_local_time(
        UserModel.objects,
        start_hour,
        end_hour,
        isoweekdays=isoweekdays
    )

    if active is not None:
        users = _filters.active_users(users, active=active)
    return users
コード例 #3
0
ファイル: filters.py プロジェクト: aweandreverence/django-htk
def users_currently_at_local_time(users, start_hour, end_hour, isoweekdays=None):
    """Filters a QuerySet of `users` whose current local time is within a time range

    Strategy 1 (inefficient):
    enumerate through every User, and keep the ones whose current local time is within the range

    Strategy 2:
    - find all the timezones that are in the local time
    - query users in that timezone

    `start_hour` and `end_hour` are naive datetimes
    If `isoweekdays` is specified, also checks that it falls on one of the days of the week (Monday = 1, Sunday = 7)
    """
    from htk.utils.datetime_utils import get_timezones_within_current_local_time_bounds    
    timezones = get_timezones_within_current_local_time_bounds(start_hour, end_hour, isoweekdays=isoweekdays)
    filtered = users.filter(
        profile__timezone__in=timezones
    )
    return filtered
コード例 #4
0
ファイル: filters.py プロジェクト: WhitespaceCrew/django-htk
def users_currently_at_local_time(users, start_hour, end_hour, isoweekdays=None):
    """Filters a QuerySet of `users` whose current local time is within a time range

    Strategy 1 (inefficient):
    enumerate through every User, and keep the ones whose current local time is within the range

    Strategy 2:
    - find all the timezones that are in the local time
    - query users in that timezone

    `start_hour` and `end_hour` are naive datetimes
    If `isoweekdays` is specified, also checks that it falls on one of the days of the week (Monday = 1, Sunday = 7)
    """
    from htk.utils.datetime_utils import get_timezones_within_current_local_time_bounds    
    timezones = get_timezones_within_current_local_time_bounds(start_hour, end_hour, isoweekdays=isoweekdays)
    filtered = users.filter(
        profile__timezone__in=timezones
    )
    return filtered