-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Sort by user name instead of id in standup - Return department on slide and user info - Add slide order in project - Properly handle events cache - Add is_superuser staff in UserMe - Fix TimeEntry types filter - Add additional fields to UserType - Deprecated standup fields
- Loading branch information
Showing
20 changed files
with
393 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,70 @@ | ||
import typing | ||
|
||
# from asgiref.sync import sync_to_async | ||
from django.db import models | ||
|
||
# import datetime | ||
|
||
|
||
# from apps.common.models import Event | ||
# from apps.journal.models import Journal | ||
# from django.utils.functional import cached_property | ||
# from strawberry.dataloader import DataLoader | ||
|
||
DjangoModel = typing.TypeVar("DjangoModel", bound=models.Model) | ||
|
||
|
||
# -- Helper | ||
def load_model_objects( | ||
Model: typing.Type[DjangoModel], | ||
keys: list[int], | ||
) -> list[DjangoModel]: | ||
qs = Model.objects.filter(id__in=keys) | ||
_map = {obj.pk: obj for obj in qs} | ||
return [_map[key] for key in keys] | ||
|
||
|
||
# -- Common models dataloaders | ||
|
||
# def load_user_last_working_date(keys: list[int]) -> list[datetime.date]: | ||
# """ | ||
# WITH recursive_days AS ( | ||
# SELECT | ||
# DATE_SUB(:input_date, INTERVAL 1 DAY) AS prev_day | ||
# UNION ALL | ||
# SELECT | ||
# DATE_SUB(prev_day, INTERVAL 1 DAY) | ||
# FROM recursive_days | ||
# WHERE | ||
# prev_day NOT IN ( | ||
# SELECT | ||
# {Event.date.db_column} | ||
# FROM {Event._meta.db_table} | ||
# WHERE {Event.type.db_column} IN ( | ||
# {Event.Type.HOLIDAY.value}, | ||
# {Event.Type.RETREAT.value} | ||
# ) | ||
# ) | ||
# AND DAYOFWEEK(prev_day) NOT IN (1, 7) -- 1 = Sunday, 7 = Saturday | ||
# AND ( | ||
# SELECT COUNT(*) FROM recursive_days | ||
# ) < %(NUMBER_OF_WORKING_DAYS_TO_SKIP + 1)s -- Stop after finding N working days | ||
# ) | ||
# SELECT MIN(prev_day) AS date_before_n_working_days | ||
# FROM recursive_days; | ||
# """ | ||
|
||
# recent_user_leave_dates_qs = ( | ||
# Journal.as_leave_qs(recent_only=True) | ||
# .filter(user__in=keys) | ||
# .values_list('user', 'date') | ||
# ) | ||
# print(recent_user_leave_dates_qs) | ||
# return load_model_objects(User, keys) | ||
|
||
|
||
class CommonLoader: | ||
# @cached_property | ||
# def load_user_last_working_date(self): | ||
# return DataLoader(load_fn=sync_to_async(load_user_last_working_date)) | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2.15 on 2024-08-26 12:01 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("project", "0005_project_is_archived_deadline"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="project", | ||
name="slide_order", | ||
field=models.PositiveSmallIntegerField(default=0, help_text="Used to order projects in daily stand-up slides"), | ||
), | ||
] |
27 changes: 27 additions & 0 deletions
27
apps/project/migrations/0007_project_logo_hd_alter_project_logo.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 4.2.15 on 2024-08-26 12:32 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("project", "0006_project_slide_order"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="project", | ||
name="logo_hd", | ||
field=models.ImageField( | ||
blank=True, help_text="Hight quality logo", max_length=255, null=True, upload_to="project/logo-hd/" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="project", | ||
name="logo", | ||
field=models.ImageField( | ||
blank=True, help_text="Low quality logo.", max_length=255, null=True, upload_to="project/logo/" | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.