28 lines
1.4 KiB
Java
28 lines
1.4 KiB
Java
package dev.dinauer.monitoring.indexing;
|
|
|
|
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
|
|
import io.quarkus.panache.common.Parameters;
|
|
import jakarta.enterprise.context.ApplicationScoped;
|
|
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
|
|
@ApplicationScoped
|
|
public class IndexMetricsRepo implements PanacheRepositoryBase<IndexCollection, String>
|
|
{
|
|
public Optional<IndexCollection> findByProperties(String resource, String metric, String timestamp, TimeUnit unit)
|
|
{
|
|
return find("resource = :resource AND metric = :metric AND timestamp = :timestamp AND unit = :unit", Parameters.with("resource", resource).and("metric", metric).and("timestamp", timestamp).and("unit", unit)).firstResultOptional();
|
|
}
|
|
|
|
public List<IndexCollection> findByResourceAndMetricAndTimeUnit(String resource, String metric, TimeUnit unit)
|
|
{
|
|
return list("resource = :resource AND metric = :metric AND unit = :unit ORDER BY timestamp ASC", Parameters.with("resource", resource).and("metric", metric).and("unit", unit));
|
|
}
|
|
|
|
public List<IndexCollection> findByResourceAndMetricAndTimeUnitAndPeriod(String resource, String metric, TimeUnit unit, long from, long to)
|
|
{
|
|
return list("resource = :resource AND metric = :metric AND unit = :unit AND (unix >= :from AND unix <= :to) ORDER BY timestamp ASC", Parameters.with("resource", resource).and("metric", metric).and("unit", unit).and("from", from).and("to", to));
|
|
}
|
|
}
|