fixed tests
This commit is contained in:
parent
5563da7c0d
commit
33eac2f778
@ -80,14 +80,15 @@ public class TbAlarmCountSubCtx extends TbAbstractEntityQuerySubCtx<AlarmCountQu
|
||||
}
|
||||
|
||||
private int countAlarms() {
|
||||
PageData<EntityData> data = entityService.findEntityDataByQuery(getTenantId(), getCustomerId(), buildEntityDataQuery());
|
||||
List<EntityId> entityIds = data.getData().stream().map(EntityData::getEntityId).toList();
|
||||
if (entityIds.isEmpty()) {
|
||||
return 0;
|
||||
} else {
|
||||
return (int) alarmService.countAlarmsByQuery(getTenantId(), getCustomerId(), query, entityIds);
|
||||
List<EntityId> entityIds = null;
|
||||
if (query.getEntityFilter() != null) {
|
||||
PageData<EntityData> data = entityService.findEntityDataByQuery(getTenantId(), getCustomerId(), buildEntityDataQuery());
|
||||
if (data.getData().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
entityIds = data.getData().stream().map(EntityData::getEntityId).toList();
|
||||
}
|
||||
|
||||
return (int) alarmService.countAlarmsByQuery(getTenantId(), getCustomerId(), query, entityIds);
|
||||
}
|
||||
|
||||
private EntityDataQuery buildEntityDataQuery() {
|
||||
|
||||
@ -17,9 +17,8 @@ package org.thingsboard.server.common.data.query;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.thingsboard.server.common.data.alarm.AlarmSearchStatus;
|
||||
import org.thingsboard.server.common.data.alarm.AlarmSeverity;
|
||||
@ -30,8 +29,7 @@ import java.util.List;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@Data
|
||||
@ToString
|
||||
public class AlarmCountQuery extends EntityCountQuery {
|
||||
private long startTs;
|
||||
|
||||
@ -27,7 +27,7 @@ import java.util.List;
|
||||
public class EntityCountQuery {
|
||||
|
||||
@Getter
|
||||
protected EntityFilter entityFilter;
|
||||
private EntityFilter entityFilter;
|
||||
|
||||
@Getter
|
||||
protected List<KeyFilter> keyFilters;
|
||||
|
||||
@ -351,8 +351,7 @@ public class BaseAlarmService extends AbstractCachedEntityService<TenantId, Page
|
||||
|
||||
@Override
|
||||
public long countAlarmsByQuery(TenantId tenantId, CustomerId customerId, AlarmCountQuery query) {
|
||||
validateId(tenantId, id -> INCORRECT_TENANT_ID + id);
|
||||
return alarmDao.countAlarmsByQuery(tenantId, customerId, query, Collections.emptyList());
|
||||
return countAlarmsByQuery(tenantId, customerId, query, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -327,7 +327,7 @@ public class DefaultAlarmQueryRepository implements AlarmQueryRepository {
|
||||
ctx.append(" and a.customer_id = :customerId and ea.customer_id = :customerId");
|
||||
ctx.addUuidParameter("customerId", customerId.getId());
|
||||
}
|
||||
if (!orderedEntityIds.isEmpty()) {
|
||||
if (orderedEntityIds != null) {
|
||||
ctx.addUuidListParameter("entity_filter_entity_ids", orderedEntityIds.stream().map(EntityId::getId).collect(Collectors.toList()));
|
||||
ctx.append(" and ea.entity_id in (:entity_filter_entity_ids)");
|
||||
}
|
||||
@ -339,7 +339,7 @@ public class DefaultAlarmQueryRepository implements AlarmQueryRepository {
|
||||
ctx.append(" and a.customer_id = :customerId");
|
||||
ctx.addUuidParameter("customerId", customerId.getId());
|
||||
}
|
||||
if (!orderedEntityIds.isEmpty()) {
|
||||
if (orderedEntityIds != null) {
|
||||
ctx.addUuidListParameter("entity_filter_entity_ids", orderedEntityIds.stream().map(EntityId::getId).collect(Collectors.toList()));
|
||||
ctx.append(" and a.originator_id in (:entity_filter_entity_ids)");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user