Skip to content

Commit

Permalink
fix getattr error
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Corny committed Apr 18, 2024
1 parent 503152c commit c31cc95
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions backend/gn_module_zh/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,14 @@ def __get_cor_rule_id(self):
DB.session.close()

def __get_id_nomenc(self, id_type: int, cd_nomenc: str) -> int:
return getattr(
DB.session.scalars(
select(TNomenclatures).where(
return DB.session.scalars(
select(TNomenclatures.id_nomenclature).where(
and_(
TNomenclatures.id_type == id_type,
TNomenclatures.cd_nomenclature == cd_nomenc,
)
)
).first(),
"id_nomenclature",
None,
)
).first()

def __get_nomencs(self, abb, cat=None):
cat_id = self.__get_id_nomenc(self.__get_id_type("HIERARCHY"), cat)
Expand Down Expand Up @@ -495,12 +491,9 @@ def __get_qualif_cat4_cat5(self):
try:
combination = self.__get_combination()
# set qualif_id
qualif_id = getattr(
DB.session.scalars(
select(TCorQualif).where(TCorQualif.combination == combination)
).first(),
"id_qualification",
)
qualif_id = DB.session.scalars(
select(TCorQualif.id_qualification).where(TCorQualif.combination == combination)
).first()
return qualif_id
except ZHApiError as e:
raise ZHApiError(
Expand Down Expand Up @@ -1206,9 +1199,10 @@ def get_denom(rb_id, col_name):
rb_name = DB.session.execute(
select(TRiverBasin.name).where(TRiverBasin.id_rb == rb_id)
).scalar_one()
return DB.session.execute(
select(RbNotesSummary.col_name).where(RbNotesSummary.bassin_versant == rb_name)
).scalar_one()
return getattr(
DB.session.execute(
select(RbNotesSummary).where(RbNotesSummary.bassin_versant == rb_name)
).scalar_one(), col_name)

@staticmethod
def get_str_note(note, denominator):
Expand Down

0 comments on commit c31cc95

Please sign in to comment.