SUM calculation appears to be same as COUNT
Closed this issue · 1 comments
Pulse Version
1.3.2
Laravel Version
11.37.0
PHP Version
8.3.8
Livewire Version
Latest
Database Driver & Version
MySQL 8.0.33
Description
I'm not sure whether this is intentional or not, but looking through the DatabaseStorage,php file, the upsert calculations for MySQL for both count and sum are the same.
count:
Expression('`value` + values(`value`)')sum:
Expression('`value` + values(`value`)')In what scenario then would sum be different from count
Steps To Reproduce
Look a DatabaseStorage.php
The data is pre-aggregated in PHP before being sent to the database to reduce the number of insert rows and work around a limitation of Postgres being unable to handle insert conflicts.
pulse/src/Storage/DatabaseStorage.php
Lines 307 to 313 in a4c64bb
pulse/src/Storage/DatabaseStorage.php
Lines 353 to 359 in a4c64bb
After this stage, insertion into the database is an addition operation for both count and sum.
You can check out the tests to confirm the behaviour.