Skip to content
Snippets Groups Projects
Unverified Commit a899b6b3 authored by Christoph Wurst's avatar Christoph Wurst
Browse files

Fix div by zero in important messages feature extractor

parent aca8c544
No related branches found
No related tags found
No related merge requests found
......@@ -61,6 +61,10 @@ class ImportantMessagesExtractor implements IExtractor {
}
public function extract(string $email): float {
return ($this->flaggedMessages[$email] ?? 0) / ($this->totalMessages[$email] ?? 0);
if (($total = $this->totalMessages[$email] ?? 0) === 0) {
// Prevent div by 0
return 0;
}
return ($this->flaggedMessages[$email] ?? 0) / $total;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment