jimu-decompiled/sources/com/ubtrobot/analytics/ActivenessStorage.java
2025-05-13 19:24:51 +02:00

92 lines
3.7 KiB
Java

package com.ubtrobot.analytics;
import android.content.Context;
import android.database.Cursor;
import android.util.Log;
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
import com.ubtrobot.analytics.ActivenessScheme;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
/* loaded from: classes2.dex */
public class ActivenessStorage {
private AnalyticsDBHelper a;
public ActivenessStorage(Context context) {
this.a = AnalyticsDBHelper.a(context);
}
public void a() throws IOException {
synchronized (this) {
String format = String.format("DELETE FROM %s WHERE %s IN(SELECT %s FROM(SELECT %s FROM %s GROUP BY %s HAVING count(%s) > 1))AND %s NOT IN(SELECT %s FROM(SELECT max(%s), %s FROM %s GROUP BY %s HAVING count(%s) > 1))", "activeness", "started_at", "started_at", "started_at", "activeness", "started_at", "started_at", "duration", "duration", "duration", "duration", "activeness", "started_at", "started_at");
Log.i("Analytics", "SQL deleteRepetition: " + format);
this.a.b(format);
}
}
public void b(ActivenessRecord activenessRecord) throws IOException {
synchronized (this) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("event_id");
stringBuffer.append(" = ? AND ");
stringBuffer.append("user_id");
stringBuffer.append(" = ? AND ");
stringBuffer.append(JockstickDataConverter.ID);
stringBuffer.append(" IN (SELECT ");
stringBuffer.append(JockstickDataConverter.ID);
stringBuffer.append(" FROM ");
stringBuffer.append("activeness");
stringBuffer.append(" ORDER BY ");
stringBuffer.append("ticktock_at");
stringBuffer.append(" DESC");
stringBuffer.append(" LIMIT 1");
stringBuffer.append(")");
this.a.a("activeness", ActivenessScheme.Converters.a(activenessRecord), stringBuffer.toString(), new String[]{activenessRecord.b(), activenessRecord.e()});
}
}
public int a(String str, int i) throws IOException {
int a;
synchronized (this) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("event_id");
stringBuffer.append(" = ? AND ");
stringBuffer.append(JockstickDataConverter.ID);
stringBuffer.append(" IN (SELECT ");
stringBuffer.append(JockstickDataConverter.ID);
stringBuffer.append(" FROM ");
stringBuffer.append("activeness");
stringBuffer.append(" ORDER BY ");
stringBuffer.append("ticktock_at");
stringBuffer.append(" ASC");
stringBuffer.append(" LIMIT ");
stringBuffer.append(i);
stringBuffer.append(")");
a = this.a.a("activeness", stringBuffer.toString(), new String[]{str});
}
return a;
}
public void a(ActivenessRecord activenessRecord) throws IOException {
synchronized (this) {
this.a.a("activeness", ActivenessScheme.Converters.a(activenessRecord));
}
}
public List<ActivenessRecord> a(String str) throws IOException {
synchronized (this) {
Cursor d = this.a.d(String.format("SELECT * FROM %s WHERE %s = '%s'", "activeness", "event_id", str));
LinkedList linkedList = new LinkedList();
if (d == null) {
return linkedList;
}
while (d.moveToNext()) {
linkedList.add(ActivenessScheme.Converters.a(d));
}
d.close();
return linkedList;
}
}
}