Skip to content

Commit

Permalink
fix sql params order in sql.go
Browse files Browse the repository at this point in the history
  • Loading branch information
cmarcoin authored and Josquin Cornec committed May 31, 2024
1 parent 6074d01 commit 887dbc1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/core/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ func (p summaryParams) toSQLScoreParams() []interface{} {
p.etatAdministratif,
p.firstAlert,
p.hasntDelai,
p.creationDateThreshold,
p.creationDateThreshold, // $24
// insert new argument before and manually update index of libelleListe
p.libelleListe,
p.libelleListe, // $25
}
}

Expand All @@ -152,7 +152,7 @@ var sqlScore = `select
s.libelle_departement, s.code_departement,
case when (permissions($1, s.roles, s.first_list_entreprise, s.code_departement, fe.siren is not null)).score then sc.score end as valeur_score,
case when (permissions($1, s.roles, s.first_list_entreprise, s.code_departement, fe.siren is not null)).score then sc.detail end as detail_score,
case when (permissions($1, s.roles, s.first_list_entreprise, s.code_departement, fe.siren is not null)).score then coalesce(s.first_list_etablissement = $23 or s.first_red_list_etablissement = $23, false) end as first_alert,
case when (permissions($1, s.roles, s.first_list_entreprise, s.code_departement, fe.siren is not null)).score then coalesce(s.first_list_etablissement = $25 or s.first_red_list_etablissement = $25, false) end as first_alert,
s.chiffre_affaire, s.arrete_bilan, s.exercice_diane, s.variation_ca, s.resultat_expl, s.effectif, s.effectif_entreprise,
s.libelle_n5, s.libelle_n1, s.code_activite, s.last_procol,
case when (permissions($1, s.roles, s.first_list_entreprise, s.code_departement, fe.siren is not null)).dgefp then s.activite_partielle end as activite_partielle,
Expand All @@ -176,7 +176,7 @@ var sqlScore = `select
(permissions($1, s.roles, s.first_list_entreprise, s.code_departement, fe.siren is not null)).bdf,
s.secteur_covid, s.excedent_brut_d_exploitation, s.etat_administratif, s.etat_administratif_entreprise, s.has_delai
from v_summaries s
inner join score0 sc on sc.siret = s.siret and sc.libelle_liste = $23 and sc.alert != 'Pas d''alerte'
inner join score0 sc on sc.siret = s.siret and sc.libelle_liste = $25 and sc.alert != 'Pas d''alerte'
left join v_naf n on n.code_n5 = s.code_activite
left join etablissement_follow f on f.active and f.siret = s.siret and f.username = $8
left join v_entreprise_follow fe on fe.siren = s.siren and fe.username = $8
Expand Down

0 comments on commit 887dbc1

Please sign in to comment.