Skip to content

Commit

Permalink
perf(api): improved loading of modules (#30)
Browse files Browse the repository at this point in the history
* Merged feat/package-module-alembic

commit 70b0139
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 15:22:56 2022 +0100

    style: apply black

commit 2badedf
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 15:11:41 2022 +0100

    chore(db): removed unused import

commit 57d9b52
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 14:47:48 2022 +0100

    feat(db): improved & finished downgrade func

commit 211780f
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 09:32:12 2022 +0100

    feat(db): wip: add upgrade and began downgrade

    Downgrade migration need a little bit more work due to the use of
    sql alchemy and not plain text sql

commit 0b5a3b8
Author: Maxime Vergez <[email protected]>
Date:   Mon Dec 5 11:40:32 2022 +0100

    feat: packaged module

* perf(api): improved loading of modules

When there are loads of datasets, the relationship takes a lot of
time to load, and is useless for the route that uses it.

* fix: due to wrong rebase

Fix: newline on data_utils.py
Fix: relationships are not joined anymore since there is no need of
them
Chore: update comment
  • Loading branch information
mvergez authored and andriacap committed Jan 16, 2023
1 parent f4efa25 commit 1db402e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion backend/gn_module_monitoring/modules/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
get_modules
"""

from sqlalchemy.orm import Load
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound

from geonature.utils.env import DB
Expand Down Expand Up @@ -87,7 +88,12 @@ def get_modules():

try:
res = (
DB.session.query(TMonitoringModules).order_by(TMonitoringModules.module_label)
DB.session.query(TMonitoringModules)
.options(
# Raise load not to load any relationship
Load(TMonitoringModules).raiseload("*")
)
.order_by(TMonitoringModules.module_label)
.all()
)

Expand Down

0 comments on commit 1db402e

Please sign in to comment.