profiler.start("deleteSnapshotWastedMeasures (project_measures)");
List<Long> metricIdsWithoutHistoricalData = purgeMapper.selectMetricIdsWithoutHistoricalData();
- if (!metricIdsWithoutHistoricalData.isEmpty()) {
- for (List<Long> partSnapshotIds : snapshotIdsPartition) {
- purgeMapper.deleteSnapshotWastedMeasures(partSnapshotIds, metricIdsWithoutHistoricalData);
- }
- session.commit();
+ for (List<Long> partSnapshotIds : snapshotIdsPartition) {
+ purgeMapper.deleteSnapshotWastedMeasures(partSnapshotIds, metricIdsWithoutHistoricalData);
}
+ session.commit();
profiler.stop();
profiler.start("updatePurgeStatusToOne (snapshots)");
</delete>
<delete id="deleteSnapshotWastedMeasures" parameterType="map">
- delete from project_measures where snapshot_id in
+ delete from project_measures
+ <where>
+ snapshot_id in
<foreach collection="snapshotIds" open="(" close=")" item="snapshotId" separator=",">
#{snapshotId}
</foreach>
- and
- (rule_id is not null or person_id is not null or metric_id in
- <foreach item="mid" index="index" collection="mids" open="(" separator="," close=")">#{mid}</foreach>
- )
+ and (rule_id is not null or person_id is not null
+ <if test="mids.size()>0">
+ or metric_id in
+ <foreach item="mid" index="index" collection="mids" open="(" separator="," close=")">#{mid}</foreach>
+ </if>)
+ </where>
</delete>
<update id="updatePurgeStatusToOne" parameterType="long">
}
@Test
- public void shouldDeleteWastedMeasuresWhenPurgingSnapshot() {
+ public void delete_wasted_measures_when_purging_snapshot() {
setupData("shouldDeleteWastedMeasuresWhenPurgingSnapshot");
SqlSession session = getMyBatis().openSession();