-
Notifications
You must be signed in to change notification settings - Fork 4
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
TECH - deplacement du calcul du score etabilssement dans un CRON #2239
Conversation
Review app: |
08ad524
to
3a5146d
Compare
back/src/domains/establishment/adapters/PgEstablishmentAggregateRepository.sql.ts
Outdated
Show resolved
Hide resolved
back/src/domains/establishment/adapters/PgEstablishmentAggregateRepository.sql.ts
Outdated
Show resolved
Hide resolved
3a5146d
to
9e206cf
Compare
9e206cf
to
121ecc9
Compare
SELECT | ||
CASE | ||
WHEN total_discussions > 0 | ||
THEN (answered_discussions::float / total_discussions) * ${discussionCountCoefficient} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
answered_discussions
peut être null. Avec postgres, la division null/total_discussions sera null, et une addition avec un null sera null aussi.
je propose:
THEN (answered_discussions::float / total_discussions) * ${discussionCountCoefficient} | |
THEN (COALESCE(answered_discussions::float, 0) / total_discussions) * ${discussionCountCoefficient} |
ou sinon de modifier plus haut dans le WITH de discussion_counts:
sql`COUNT(DISTINCT
CASE WHEN exchanges.sender = 'establishment'::exchange_role THEN d.id
ELSE 0 // par défaut sans ce else, ce sera NULL
END)`.as(
"answered_discussions",
),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il y a bien un coalesce
mais à la sortie du select (line 171). Pour moi ça revient au même.
J'ai joué la query sur le replicat, et j'ai pas eu de problème (sachant que score
est obligatoire, on aurait vu un problème en essayant de le mettre à null)
121ecc9
to
0871d90
Compare
No description provided.