Skip to content

Commit c5441da

Browse files
committed
fix: a diagram on collection page shows incorrect number of stamps by categories when a user has an incomplete series.
Fix half of #1143
1 parent 7de0591 commit c5441da

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/main/resources/sql/category_dao_queries.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ SELECT COUNT(*) \
5858

5959
category.count_stamps_by_categories = \
6060
SELECT CASE WHEN 'ru' = :lang THEN COALESCE(c.name_ru, c.name) ELSE c.name END AS name \
61-
, SUM(s.quantity) AS counter \
61+
, SUM(cs.number_of_stamps) AS counter \
6262
FROM collections_series cs \
6363
JOIN series s \
6464
ON s.id = cs.series_id \

src/test/java/ru/mystamps/web/feature/category/JdbcCategoryDaoTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,27 @@ public void getStatisticsOfWithSeriesWithAllStamps() {
9393
.hasSize(2);
9494
}
9595

96+
@Test
97+
@Sql(
98+
scripts = {
99+
"/db/users-coder.sql",
100+
"/db/collections-coder.sql",
101+
"/db/categories-fauna.sql",
102+
"/db/series-1-fauna-qty5.sql",
103+
},
104+
statements = {
105+
"INSERT INTO collections_series(collection_id, series_id, number_of_stamps) "
106+
+ "VALUES (1, 1, 2)"
107+
}
108+
)
109+
public void getStatisticsOfWithIncompleteSeries() {
110+
// given
111+
// when
112+
Map<String, Integer> statistics = categoryDao.getStatisticsOf(1, "en");
113+
// then
114+
assertThat(statistics).containsEntry("Fauna", 2);
115+
}
116+
96117
@Test
97118
@Sql(
98119
scripts = {

0 commit comments

Comments
 (0)