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

TECH - deplacement du calcul du score etabilssement dans un CRON #2239

Merged
merged 4 commits into from
Sep 26, 2024

Conversation

JeromeBu
Copy link
Collaborator

No description provided.

Copy link

@JeromeBu JeromeBu marked this pull request as draft September 25, 2024 06:38
@JeromeBu JeromeBu changed the title create CRON job to update establishment score TECH - deplacement du calcul du score etabilssement dans un CRON Sep 25, 2024
@JeromeBu JeromeBu force-pushed the TECH-calcul-du-score-etablissement-en-CRON branch from 08ad524 to 3a5146d Compare September 25, 2024 08:02
@JeromeBu JeromeBu marked this pull request as ready for review September 25, 2024 09:06
SELECT
CASE
WHEN total_discussions > 0
THEN (answered_discussions::float / total_discussions) * ${discussionCountCoefficient}
Copy link
Contributor

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:

Suggested change
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",
          ),

Copy link
Collaborator Author

@JeromeBu JeromeBu Sep 26, 2024

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)

@celineung celineung enabled auto-merge (rebase) September 26, 2024 12:11
@celineung celineung merged commit e03131a into main Sep 26, 2024
14 checks passed
@celineung celineung deleted the TECH-calcul-du-score-etablissement-en-CRON branch September 26, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants