-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨(teams) add Team dependencies #560
base: main
Are you sure you want to change the base?
Conversation
34da950
to
312bb54
Compare
312bb54
to
0d2b578
Compare
ed99015
to
9ad2678
Compare
9ad2678
to
94ab00e
Compare
500ec8f
to
7e6037b
Compare
src/backend/core/migrations/0010_team_depth_team_numchild_team_path_and_more.py
Outdated
Show resolved
Hide resolved
e7202a1
to
9b32890
Compare
a2e7d74
to
dc848dd
Compare
# This might be changed later if we never do any operation on the parent object | ||
# before creating the child. | ||
# Beware the N+1 here. | ||
return self.get(pk=parent_id).add_child(**kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not expect the parent object directly? It seems to me what we expect when playing with objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use the object directly to be safer (even if sub-optimized) because as stated in django-treebeard documentation, it's important to have nodes up to date when doing such operations.
Do you think I should update the comment?
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | ||
# Django treebeard does not allow max_length = None... | ||
steplen = 5 | ||
path = models.CharField(max_length=5 * 80, unique=True, db_collation="C") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if this collation impacts the use of "startswith" 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the C collation can improve database performance for certain operations, like sorting and comparison, because it uses simple byte-wise comparison rather than more complex locale-aware rules. However, this comes at the cost of losing locale-specific behaviors, such as case insensitivity and proper sorting for different languages.
So I guess it's only better :) Actually it still works properly in the specific case of "startswith" but I can't tell for the performance improvement or not.
pytestmark = pytest.mark.django_db | ||
|
||
|
||
@override_settings(DEBUG=True) | ||
@mock.patch.dict(defaults.NB_OBJECTS, TEST_NB_OBJECTS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not mock? It allows to run it with less objects in tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the tests were not failing with the amount of objects in this tests, yet the command was failing. So I guess it was better to test the command as it is.
name = fake.domain_name() | ||
|
||
if name in excluded: | ||
raise RuntimeError("Could not find a domain name that is not already created") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or add a iteration number aftter the domain? 🤷♂️
|
||
def test_models_teams_delete_team(): | ||
""" | ||
Delete a parent team also deletes children. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in practice this will force you to introduce soft delete soon enough! 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably ^^ but for now this feature is hidden from end users, so I keep it for later when we need it.
This provides the technical way to create Team trees. The implementation is quite naive.
Also return the parent teams in the user's team endpoints. This is a first implementation which returns a flat list of teams (not a tree). This is not really helpful, but it allows to create hierarchical teams manually (via admin) if an organization needs it.
Also return the parent teams in the user's team endpoints.
This will allow the frontend to represent teams as a tree if needed.
dc848dd
to
26b1880
Compare
Purpose
We want to allow Teams to be structured in trees to represent actual teams in a company.
Proposal
Add the "tree" to the Team model and update the API endpoints to list parent teams along with the "direct" teams the user has access to.
This first implementation only allows to manually create those team trees.
The API returns flat teams because we did not define the frontend behavior yet, this will be done later when we really know what we want.
The Treebeard has been pimped for PSQL use, and make the different values explicit.
django-treebeard
dependencyTeam
model into an MP node