count assets by tenantId improvements

This commit is contained in:
YevhenBondarenko 2020-11-25 11:05:36 +02:00 committed by Andrew Shvayka
parent e39e37babf
commit 7cd2a870f5
2 changed files with 3 additions and 2 deletions

View File

@ -122,5 +122,5 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
@Query("SELECT DISTINCT a.type FROM AssetEntity a WHERE a.tenantId = :tenantId")
List<String> findTenantAssetTypes(@Param("tenantId") UUID tenantId);
Long countByTenantId(UUID tenantId);
Long countByTenantIdAndTypeIsNot(UUID tenantId, String type);
}

View File

@ -44,6 +44,7 @@ import java.util.UUID;
*/
@Component
public class JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao {
public static final String TB_SERVICE_QUEUE = "TbServiceQueue";
@Autowired
private AssetRepository assetRepository;
@ -179,6 +180,6 @@ public class JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> im
@Override
public Long countByTenantId(TenantId tenantId) {
return assetRepository.countByTenantId(tenantId.getId());
return assetRepository.countByTenantIdAndTypeIsNot(tenantId.getId(), TB_SERVICE_QUEUE);
}
}