Skip to content

Commit

Permalink
models: avoid flushing when getting records
Browse files Browse the repository at this point in the history
  • Loading branch information
ntarocco authored and zzacharo committed Sep 18, 2023
1 parent 694c124 commit 167f24d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions invenio_users_resources/records/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ def from_user(cls, user):
# TODO
data = parse_user_data(user)

model = cls.model_cls(data, model_obj=user)
user_agg = cls(data, model=model)
return user_agg
with db.session.no_autoflush:
model = cls.model_cls(data, model_obj=user)
user_agg = cls(data, model=model)
return user_agg

@classmethod
def get_record(cls, id_):
Expand Down Expand Up @@ -278,10 +279,11 @@ def from_role(cls, role):
# TODO
data = parse_role_data(role)

model = cls.model_cls(data, model_obj=role)
role_agg = cls(data, model=model)
role_agg._role = role
return role_agg
with db.session.no_autoflush:
model = cls.model_cls(data, model_obj=role)
role_agg = cls(data, model=model)
role_agg._role = role
return role_agg

@classmethod
def get_record(cls, id_):
Expand Down
2 changes: 1 addition & 1 deletion invenio_users_resources/services/users/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def create(self, identity, data, raise_errors=True, uow=None):
)

def search(self, identity, params=None, search_preference=None, **kwargs):
"""Search for records matching the querystring."""
"""Search for active and confirmed users, matching the querystring."""
return super().search(
identity,
params=params,
Expand Down

0 comments on commit 167f24d

Please sign in to comment.