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

/collection/{slug}/estimation: optimize summing of prices #888

Open
0pdd opened this issue Jun 21, 2018 · 3 comments
Open

/collection/{slug}/estimation: optimize summing of prices #888

0pdd opened this issue Jun 21, 2018 · 3 comments
Labels
area/optimization This change could speed up our site techdebt
Milestone

Comments

@0pdd
Copy link

0pdd commented Jun 21, 2018

The puzzle 884-03637f5c from #884 has to be resolved:

@todo #884 /collection/{slug}/estimation: optimize summing of prices

The puzzle was created by Slava Semushin on 20-Jun-18.

@0pdd
Copy link
Author

0pdd commented Jun 21, 2018

The puzzle 884-03637f5c has disappeared from the source code, that's why I closed this issue.

@php-coder
Copy link
Owner

php-coder commented Jun 21, 2018

Here is the sql query for that:

select sum(price) as total,currency from collections_series where price is not null group by currency;
+---------+----------+
| total   | currency |
+---------+----------+
|  300.00 | EUR      |
| 2137.50 | RUB      |
|  150.00 | USD      |
+---------+----------+
3 rows in set (0.00 sec)

@php-coder php-coder added this to the next milestone Jun 21, 2018
@php-coder
Copy link
Owner

php-coder commented Jan 23, 2020

Yet another way is to use window functions and get total price together with data:

SUM(cs.price) OVER(PARTITION BY cs.currency) AS total_price

But such data list will be hard to process from within Thymeleaf, so we can apply a little transformation on DAO layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/optimization This change could speed up our site techdebt
Projects
None yet
Development

No branches or pull requests

2 participants