From 14d3f76ac1f3be157a144f524261ad6c1c008524 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Tue, 9 Nov 2021 18:16:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=BF=98=E8=AE=B0=E5=86=99?= =?UTF-8?q?=E7=9A=84=20tracker/0/0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cono/morny/data/tracker/TrackerDataManager.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java b/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java index 6680b9f..1695a24 100644 --- a/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java +++ b/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java @@ -30,6 +30,7 @@ public class TrackerDataManager { long lastWaitTimestamp = System.currentTimeMillis(); boolean postProcess = false; do { + lastWaitTimestamp += 10 * 60 * 1000; long sleeping = lastWaitTimestamp - System.currentTimeMillis(); if (sleeping > 0) { try { Thread.sleep(sleeping); } catch (InterruptedException e) { interrupt(); } @@ -41,7 +42,6 @@ public class TrackerDataManager { postProcess = true; logger.warn("last tracker write in this processor!"); } - lastWaitTimestamp += 10 * 60 * 1000; if (record.size() != 0) { logger.info("start writing tracker data."); save(reset()); @@ -78,6 +78,14 @@ public class TrackerDataManager { private static void save (HashMap>> record) { + { + if (!record.containsKey(0L)) record.put(0L, new HashMap<>()); + HashMap> chatUsers = record.get(0L); + if (!chatUsers.containsKey(0L)) chatUsers.put(0L, new TreeSet<>()); + TreeSet userRecords = chatUsers.get(0L); + userRecords.add(System.currentTimeMillis()); + } + record.forEach((chat, chatUsers) -> chatUsers.forEach((user, userRecords) -> { long dayCurrent = -1; @@ -103,6 +111,7 @@ public class TrackerDataManager { e.printStackTrace(System.out); } } + })); }