From 6412698e1dc06db48bea0459ca5238fb3ab2c52e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 7 Nov 2018 19:14:04 +0300 Subject: fix stats queries --- .../src/main/java/com/juick/server/api/xnodeinfo2/Info.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'juick-server/src/main/java/com') diff --git a/juick-server/src/main/java/com/juick/server/api/xnodeinfo2/Info.java b/juick-server/src/main/java/com/juick/server/api/xnodeinfo2/Info.java index 0c6328c6..c12df55f 100644 --- a/juick-server/src/main/java/com/juick/server/api/xnodeinfo2/Info.java +++ b/juick-server/src/main/java/com/juick/server/api/xnodeinfo2/Info.java @@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.inject.Inject; import java.time.Instant; +import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.Arrays; @@ -34,8 +35,10 @@ public class Info { nodeInfo.setServices(serviceInfo); UserStats userStats = new UserStats(); userStats.setTotal(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM users WHERE banned=0", Integer.class)); - userStats.setActiveMonth(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM users WHERE banned=0 AND last_seen > ?", Integer.class, Instant.now().minus(1, ChronoUnit.MONTHS))); - userStats.setActiveHalfyear(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM users WHERE banned=0 AND last_seen > ?", Integer.class, Instant.now().minus(6, ChronoUnit.MONTHS))); + userStats.setActiveMonth(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM users WHERE banned=0 AND last_seen > ?", + Integer.class, ZonedDateTime.now().minus(1, ChronoUnit.MONTHS).toInstant())); + userStats.setActiveHalfyear(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM users WHERE banned=0 AND last_seen > ?", + Integer.class, ZonedDateTime.now().minus(6, ChronoUnit.MONTHS).toInstant())); Usage usage = new Usage(); usage.setUsers(userStats); usage.setLocalPosts(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM messages", -- cgit v1.2.3