Skip to content
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

feat: improve perf route biblistes #585

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apptax/taxonomie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ def nb_taxons(self):
@nb_taxons.expression
def nb_taxons(cls):
return (
db.select([db.func.count(cor_nom_liste.id_liste)])
.where(BibListes.id_liste == cls.id_liste)
db.select([db.func.count(cor_nom_liste.c.id_liste)])
.where(cor_nom_liste.c.id_liste == cls.id_liste)
.label("nb_taxons")
)

Expand Down
16 changes: 10 additions & 6 deletions apptax/taxonomie/routesbiblistes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@

@adresses.route("/", methods=["GET"])
@json_resp
def get_biblistes(id=None):
def get_biblistes():
"""
retourne les contenu de bib_listes dans "data"
et le nombre d'enregistrements dans "count"
"""
data = db.session.query(BibListes).all()
biblistes_records = db.session.query(

Check warning on line 32 in apptax/taxonomie/routesbiblistes.py

View check run for this annotation

Codecov / codecov/patch

apptax/taxonomie/routesbiblistes.py#L32

Added line #L32 was not covered by tests
BibListes.id_liste, BibListes.code_liste, BibListes.nom_liste, BibListes.nb_taxons
).all()
biblistes_schema = BibListesSchema()
maliste = {"data": [], "count": 0}
maliste["count"] = len(data)
maliste["data"] = biblistes_schema.dump(data, many=True)
return maliste
biblistes_infos = {

Check warning on line 36 in apptax/taxonomie/routesbiblistes.py

View check run for this annotation

Codecov / codecov/patch

apptax/taxonomie/routesbiblistes.py#L36

Added line #L36 was not covered by tests
"data": biblistes_schema.dump(biblistes_records, many=True),
"count": len(biblistes_records),
}

return biblistes_infos

Check warning on line 41 in apptax/taxonomie/routesbiblistes.py

View check run for this annotation

Codecov / codecov/patch

apptax/taxonomie/routesbiblistes.py#L41

Added line #L41 was not covered by tests


@adresses.route("/<regne>", methods=["GET"], defaults={"group2_inpn": None})
Expand Down
Loading