diff options
author | Vitaly Takmazov | 2018-11-07 19:14:04 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-11-07 19:14:04 +0300 |
commit | 6412698e1dc06db48bea0459ca5238fb3ab2c52e (patch) | |
tree | b6a167f27b0e49e674aa51b3ee7d570bd0524232 /juick-server/src | |
parent | 0541dc6e943f4c53c3be57dbe83e1324dbd1e068 (diff) |
fix stats queries
Diffstat (limited to 'juick-server/src')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/xnodeinfo2/Info.java | 7 | ||||
-rw-r--r-- | 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 { |