Skip to content

Commit 7c2c361

Browse files
committed
fix: a diagram on collection page shows incorrect number of stamps by countries when a user has an incomplete series.
Fix the last half of #1143
1 parent 50703a3 commit 7c2c361

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/main/resources/sql/country_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
country.count_stamps_by_countries = \
6060
SELECT COALESCE(CASE WHEN 'ru' = :lang THEN COALESCE(c.name_ru, c.name) ELSE c.name END, 'Unknown') 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/country/JdbcCountryDaoTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,28 @@ public void getStatisticsOfWithSeriesWithAllStamps() {
9494
.hasSize(2);
9595
}
9696

97+
@Test
98+
@Sql(
99+
scripts = {
100+
"/db/users-coder.sql",
101+
"/db/collections-coder.sql",
102+
"/db/categories-sport.sql",
103+
"/db/countries-italy.sql",
104+
"/db/series-4-italy-qty5.sql"
105+
},
106+
statements = {
107+
"INSERT INTO collections_series(collection_id, series_id, number_of_stamps) "
108+
+ "VALUES (1, 4, 2)"
109+
}
110+
)
111+
public void getStatisticsOfWithIncompleteSeries() {
112+
// given
113+
// when
114+
Map<String, Integer> statistics = countryDao.getStatisticsOf(1, "en");
115+
// then
116+
assertThat(statistics).containsEntry("Italy", 2);
117+
}
118+
97119
@Test
98120
@Sql(
99121
scripts = {

0 commit comments

Comments
 (0)