mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Statistics: added projectOpened persisting (IDEA-CR-22562)
Removed code for persisting statistics on close. Added statistics persisting with delay on project opening.
This commit is contained in:
+4
-13
@@ -16,7 +16,6 @@
|
||||
package com.intellij.internal.statistic.persistence;
|
||||
|
||||
import com.intellij.concurrency.JobScheduler;
|
||||
import com.intellij.ide.AppLifecycleListener;
|
||||
import com.intellij.internal.statistic.UsagesCollector;
|
||||
import com.intellij.internal.statistic.beans.GroupDescriptor;
|
||||
import com.intellij.internal.statistic.beans.UsageDescriptor;
|
||||
@@ -44,7 +43,8 @@ import java.util.concurrent.TimeUnit;
|
||||
public class ApplicationStatisticsPersistenceComponent extends ApplicationStatisticsPersistence implements
|
||||
PersistentStateComponent<Element>,
|
||||
BaseComponent {
|
||||
private boolean persistOnClosing = false;
|
||||
// 30 minutes considered enough for project indexing and other tasks
|
||||
private static final int DELAY_IN_MIN = 30;
|
||||
|
||||
private static final String TOKENIZER = ",";
|
||||
|
||||
@@ -161,20 +161,11 @@ public class ApplicationStatisticsPersistenceComponent extends ApplicationStatis
|
||||
@Override
|
||||
public void initComponent() {
|
||||
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
|
||||
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void appClosing() {
|
||||
persistOpenedProjects();
|
||||
persistOnClosing = false;
|
||||
}
|
||||
});
|
||||
|
||||
connection.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {
|
||||
@Override
|
||||
public void projectClosing(Project project) {
|
||||
if (persistOnClosing && project != null) {
|
||||
UsagesCollector.doPersistProjectUsages(project);
|
||||
}
|
||||
public void projectOpened(Project project) {
|
||||
JobScheduler.getScheduler().schedule(() -> UsagesCollector.doPersistProjectUsages(project), DELAY_IN_MIN, TimeUnit.MINUTES);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user