(improvement)(Headless) Filter metrics and dimensions based on whether they were created as tags (#866)

Co-authored-by: jolunoluo
This commit is contained in:
LXW
2024-03-27 20:20:07 +08:00
committed by GitHub
parent 1d3810b173
commit fd33266e8a
8 changed files with 77 additions and 38 deletions

View File

@@ -9,4 +9,6 @@ public class PageMetricReq extends PageSchemaItemReq {
private String type;
private Integer isTag;
}

View File

@@ -9,8 +9,8 @@ import com.tencent.supersonic.headless.server.persistence.mapper.MetricQueryDefa
import com.tencent.supersonic.headless.server.persistence.repository.MetricRepository;
import com.tencent.supersonic.headless.server.pojo.MetricFilter;
import com.tencent.supersonic.headless.server.pojo.MetricsFilter;
import java.util.List;
import org.springframework.stereotype.Component;
import java.util.List;
@Component

View File

@@ -34,6 +34,8 @@ public class MetaFilter {
private List<String> fieldsDepend;
private Integer isTag;
public MetaFilter(List<Long> modelIds) {
this.modelIds = modelIds;
}

View File

@@ -117,52 +117,54 @@
<select id="query" resultMap="ResultMapWithBLOBs">
select *
from s2_dimension
from s2_dimension t
left join (
select *
from s2_tag
where type = 'DIMENSION'
) t1 on t.id = t1.item_id
where status != 3
<if test="key != null and key != ''">
and ( id like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
biz_name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
alias like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
description like CONCAT('%',#{key , jdbcType=VARCHAR},'%') )
and ( t.id like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
t.name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
t.biz_name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
t.alias like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
t.description like CONCAT('%',#{key , jdbcType=VARCHAR},'%') )
</if>
<if test="id != null">
and id like CONCAT('%',#{id , jdbcType=VARCHAR},'%')
and t.id like CONCAT('%',#{id , jdbcType=VARCHAR},'%')
</if>
<if test="name != null and name != '' ">
and name like CONCAT('%',#{name , jdbcType=VARCHAR},'%')
and t.name like CONCAT('%',#{name , jdbcType=VARCHAR},'%')
</if>
<if test="bizName != null and bizName != ''">
and biz_name like CONCAT('%',#{bizName , jdbcType=VARCHAR},'%')
and t.biz_name like CONCAT('%',#{bizName , jdbcType=VARCHAR},'%')
</if>
<if test="sensitiveLevel != null">
and sensitive_level = #{sensitiveLevel}
and t.sensitive_level = #{sensitiveLevel}
</if>
<if test="status != null">
and status = #{status}
and t.status = #{status}
</if>
<if test="modelIds != null and modelIds.size >0">
and model_id in
and t.model_id in
<foreach collection="modelIds" index="index" item="model" open="(" close=")"
separator=",">
#{model}
</foreach>
</if>
<if test="ids != null and ids.size >0">
and id in
and t.id in
<foreach collection="ids" index="index" item="id" open="(" close=")"
separator=",">
#{id}
</foreach>
</if>
<if test="createdBy != null">
and created_by = #{createdBy}
and t.created_by = #{createdBy}
</if>
<if test="isTag != null and isTag == 1">
and is_tag = 1
</if>
<if test="isTag != null and isTag == 0">
and (is_tag = 0 or is_tag is null)
and t1.id is not null
</if>
</select>

View File

@@ -98,52 +98,60 @@
</update>
<select id="query" resultMap="ResultMapWithBLOBs">
select *
from s2_metric
where status != 3
select t.*
from s2_metric t
left join (
select *
from s2_tag
where type = 'METRIC'
) t1 on t.id = t1.item_id
where t.status != 3
<if test="type != null and type != ''">
and type = #{type}
and t.type = #{type}
</if>
<if test="key != null and key != ''">
and ( id like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
biz_name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
description like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
alias like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
classifications like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
created_by like CONCAT('%',#{key , jdbcType=VARCHAR},'%') )
and ( t.id like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
t.name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
t.biz_name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
t.description like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
t.alias like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
t.classifications like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
t.created_by like CONCAT('%',#{key , jdbcType=VARCHAR},'%') )
</if>
<if test="id != null">
and id like CONCAT('%',#{id , jdbcType=VARCHAR},'%')
and t.id like CONCAT('%',#{id , jdbcType=VARCHAR},'%')
</if>
<if test="name != null and name != '' ">
and name like CONCAT('%',#{name , jdbcType=VARCHAR},'%')
and t.name like CONCAT('%',#{name , jdbcType=VARCHAR},'%')
</if>
<if test="bizName != null and bizName != ''">
and biz_name like CONCAT('%',#{bizName , jdbcType=VARCHAR},'%')
and t.biz_name like CONCAT('%',#{bizName , jdbcType=VARCHAR},'%')
</if>
<if test="sensitiveLevel != null">
and sensitive_level = #{sensitiveLevel}
and t.sensitive_level = #{sensitiveLevel}
</if>
<if test="status != null">
and status = #{status}
and t.status = #{status}
</if>
<if test="modelIds != null and modelIds.size >0">
and model_id in
and t.model_id in
<foreach collection="modelIds" index="index" item="model" open="(" close=")"
separator=",">
#{model}
</foreach>
</if>
<if test="ids != null and ids.size >0">
and id in
and t.id in
<foreach collection="ids" index="index" item="id" open="(" close=")"
separator=",">
#{id}
</foreach>
</if>
<if test="createdBy != null">
and created_by = #{createdBy}
and t.created_by = #{createdBy}
</if>
<if test="isTag != null and isTag == 1">
and t1.id is not null
</if>
</select>