Skip to content

Commit

Permalink
[Minor] Added logging of time to init report
Browse files Browse the repository at this point in the history
  • Loading branch information
eitch committed Nov 28, 2023
1 parent 7867f20 commit ec72200
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions service/src/main/java/li/strolch/report/Report.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package li.strolch.report;

import static li.strolch.report.ReportConstants.TYPE_REPORT;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

import com.google.gson.JsonObject;
import li.strolch.model.Resource;
import li.strolch.model.StrolchRootElement;
Expand All @@ -16,19 +9,34 @@
import li.strolch.report.policy.ReportPolicy;
import li.strolch.utils.collections.DateRange;
import li.strolch.utils.collections.MapOfSets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

import static li.strolch.report.ReportConstants.TYPE_REPORT;
import static li.strolch.utils.helper.StringHelper.formatMillisecondsDuration;

public class Report implements AutoCloseable {

private static final Logger logger = LoggerFactory.getLogger(Report.class);

private final ReportPolicy reportPolicy;

public Report(StrolchTransaction tx, String reportId) {

Resource reportRes = tx.getResourceBy(TYPE_REPORT, reportId, true);
PolicyDef reportPolicyDef = reportRes.getPolicyDef(ReportPolicy.class.getSimpleName());

long start = System.currentTimeMillis();
PolicyHandler policyHandler = tx.getContainer().getComponent(PolicyHandler.class);
this.reportPolicy = policyHandler.getPolicy(reportPolicyDef, tx);
this.reportPolicy.initialize(reportId);
long took = System.currentTimeMillis() - start;
logger.info("Initializing report " + reportId + " took " + formatMillisecondsDuration(took));
}

public ReportPolicy getReportPolicy() {
Expand Down

0 comments on commit ec72200

Please sign in to comment.