LH 1 gadu atpakaļ
vecāks
revīzija
99b14565da

+ 2 - 0
PlaceDECSVWiggler/.gitignore

@@ -0,0 +1,2 @@
+PlaceDECSVWiggler-SNAPSHOT.zip
+PlaceDECSVWiggler-SRC.zip

+ 27 - 0
PlaceDECSVWiggler/build.gradle

@@ -0,0 +1,27 @@
+defaultTasks 'distZip'
+
+apply plugin: 'java-library'
+apply plugin: 'application'
+
+
+sourceCompatibility = 1.17
+version = 'SNAPSHOT'
+mainClassName = 'de.nplusc.izc.placeDE.Cookies.CSVWiggler'
+
+
+jar{
+	manifest{
+		attributes 'Implementation-Title': 'senabitwiggler',
+					'Implementation-Version': 'SNAPSHOT',
+					'Main-Class': 'de.nplusc.izc.placeDE.Cookies.CSVWiggler'
+					
+	}
+}
+
+repositories{
+	mavenCentral()
+}
+
+dependencies{
+	implementation 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
+}

+ 127 - 0
PlaceDECSVWiggler/src/main/java/de/nplusc/izc/placeDE/Cookies/CSVWiggler.java

@@ -0,0 +1,127 @@
+package de.nplusc.izc.placeDE.Cookies;
+
+import java.io.*;
+import java.util.HashSet;
+
+import com.eclipsesource.json.*;
+
+public class CSVWiggler {
+    private static final String EVT_SYS_ID = "958372977714540574";
+    public static void main(String[] args) {
+
+        if(args.length<1)
+        {
+            System.err.println("Filename missing");
+        }
+
+
+        File checkme = new File(args[0]);
+        if(!checkme.exists())
+        {
+            System.err.println("File not found");
+        }
+        try {
+            String intermediateFile = args[0] + ".converted.csv";
+            String cookies = args[0] + ".cookiemetadata.csv";
+            String mionutely = args[0] + ".minutemetadata.csv";
+
+            JsonObject obj = Json.parse(new FileReader(args[0])).asObject();
+            JsonArray arr = obj.get("messages").asArray();
+            PrintWriter w = new PrintWriter(new FileWriter(intermediateFile));
+            w.println("type;author;length;cookiecount;timestamp");
+            for (int i = 0; i < arr.size(); i++) {
+                boolean isEventSys = false;
+                JsonObject msg = arr.get(i).asObject();
+                JsonObject author = msg.get("author").asObject();
+                String id = author.getString("id", "---");
+                if (id.equals(EVT_SYS_ID)) {
+                    isEventSys = true;
+                    System.out.println("Eventsys");
+                }
+
+                String message = msg.getString("content", "");
+
+                int len = message.length();
+                String timestamp = msg.getString("timestamp", "");//.substring(0, 19);
+                int cookiecount = 0;
+                String type = "default";
+                if (isEventSys) {
+                    type = "leaderboard";
+                    JsonArray embeds = msg.get("embeds").asArray();
+                    if (!(embeds.size() == 0)) {
+                        JsonObject embed = embeds.get(0).asObject();
+                        String title = embed.getString("title", "");
+                        if (title.equals("Gesammelte Cookies")) {
+                            type = "cookie";
+                            String description = embed.getString("description", "0");
+                            String cntS = description.replace("Ihr konntet ", "").replace(" Cookies sammeln.", "").replace(" Cookie sammeln.", "");
+                            cookiecount = Integer.valueOf(cntS);
+                        }
+                    }
+                }
+                w.println(type + ";" + id + ";" + len + ";" + cookiecount + ";" + timestamp);
+            }
+            w.close();
+
+            w = new PrintWriter(new FileWriter(cookies));
+            PrintWriter w2 = new PrintWriter(new FileWriter(mionutely));
+
+            BufferedReader r = new BufferedReader(new FileReader(intermediateFile));
+            int lns = -100000;
+            int lnsMinutely = -100000;
+            String line = r.readLine();
+            line = r.readLine(); //datei köpfen
+            HashSet<String> users = new HashSet<>();
+            HashSet<String> usersMinutely = new HashSet<>();
+            String previousLineTS = "";
+
+            w.println("cookiedelta;usercount;type;author;length;cookiecount;timestamp");
+            w2.println("usercount;msgsMinute;timestamp");
+            while (line != null) {
+                String[] splitted = line.split(";");
+                if (line.contains("cookie;")) {
+                    String lnp = lns+"";
+                    if (lns < 0) {
+                        lnp = "-";
+                    }
+                    System.out.println(lns+"|"+lnp);
+                    w.println(lnp+";" +users.size()+";"+ line);
+                    lns = 0;
+                    users=new HashSet<>();
+                } else {
+                    String uid = splitted[1];
+                    if(!uid.equals(EVT_SYS_ID))
+                    {
+                        lns++;
+                        users.add(uid);
+                    }
+                }
+
+                String tsMinutely = splitted[4].substring(0, 16);
+                if(!previousLineTS.equals(tsMinutely))
+                {
+                    previousLineTS=tsMinutely;
+                    if(lnsMinutely>=0)
+                    {
+                        w2.println(+usersMinutely.size()+";"+lnsMinutely+";"+previousLineTS);
+                    }
+                    lnsMinutely=0;
+                    usersMinutely=new HashSet<>();
+                }
+                String uid = splitted[1];
+                if(!uid.equals(EVT_SYS_ID))
+                {
+                    lnsMinutely++;
+                    usersMinutely.add(uid);
+                }
+                line = r.readLine();
+            }
+            w.close();
+            w2.close();
+        }
+        catch (IOException ex)
+        {
+            ex.printStackTrace();
+        }
+    }
+}

+ 5 - 5
QuickStuff/src/main/java/QuickVerifyCrap/EVS_CTR.java

@@ -6,14 +6,14 @@ import java.io.*;
 
 
 public class EVS_CTR {
-    static boolean switcheroo = true;
+    static boolean switcheroo = false;
     public static void main(String[] args) throws Exception{
 
         if(switcheroo)
         {
-            JsonObject obj = Json.parse(new FileReader("C:\\lmaa\\placeDE-exceling\\in.json")).asObject();
+            JsonObject obj = Json.parse(new FileReader("C:\\lmaa\\placeDE-exceling\\in2.json")).asObject();
             JsonArray arr = obj.get("messages").asArray();
-            PrintWriter w = new PrintWriter(new FileWriter("C:\\lmaa\\placeDE-exceling\\synthetic.csv"));
+            PrintWriter w = new PrintWriter(new FileWriter("C:\\lmaa\\placeDE-exceling\\synthetic2.csv"));
             w.println("type;author;length;cookiecount;timestamp");
             for (int i = 0; i < arr.size(); i++)
             {
@@ -56,12 +56,12 @@ public class EVS_CTR {
         }
         else
         {
-            BufferedReader r = new BufferedReader(new FileReader("C:\\lmaa\\placeDE-exceling\\in2.csv"));
+            BufferedReader r = new BufferedReader(new FileReader("C:\\lmaa\\placeDE-exceling\\synthetic2.csv"));
             int lns=0;
             String line = r.readLine();
             while(line!=null)
             {
-                if(line.contains(",\"EventSystem#0907\""))
+                if(line.contains("cookie;"))
                 {
                     System.out.println(lns+"|"+line);
                     lns=0;

+ 1 - 1
settings.gradle

@@ -1,4 +1,4 @@
 include 'ToolKit','iZpl',  'IZSetup','WPCMGr','UpidTK', 'izstreamer', 'LogBlockHeatMapper','iZlaunch',
 'iZpaqSFX','MazeViewer','TWPUtil',"iZplPlugins:WMP","iZplPlugins:foobar2000_others","iZplPlugins:itunes","iZplPlugins:GameRadio",
 "iZplPlugins:Editor","izpl-shared","iZpl-server","iZplPlugins:Smartphonizer","QuickStuff","external:java-progressbar","iZplPlugins:rtsslink","iZplPlugins:JukeBox",
-"iZplPlugins:Extractor","spungit_deathtimer","iZplPlugins:discordjukebox","SenaBitWiggler"
+"iZplPlugins:Extractor","spungit_deathtimer","iZplPlugins:discordjukebox","SenaBitWiggler","PlaceDECSVWiggler"