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 +++++-- juick-server/src/test/java/com/juick/server/tests/ServerTests.java | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) 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", diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java index 5383536a..1c643d86 100644 --- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java @@ -1767,6 +1767,8 @@ public class ServerTests { MvcResult result = mockMvc.perform(get("/.well-known/host-meta")) .andExpect(status().isOk()).andReturn(); String xrd = result.getResponse().getContentAsString(); + result = mockMvc.perform(get("/.well-known/x-nodeinfo2")) + .andExpect(status().isOk()).andReturn(); } @Test public void pms() throws Exception { -- cgit v1.2.3