import com.google.common.collect.Lists;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.CheckForNull;
return executeLargeInputs(snapshotIds, mapper(dbSession)::selectByIds);
}
+ public Optional<SnapshotDto> selectByUuid(DbSession dbSession, String analysisUuid) {
+ List<SnapshotDto> dtos = mapper(dbSession).selectByUuids(Collections.singletonList(analysisUuid));
+ if (dtos.isEmpty()) {
+ return Optional.empty();
+ }
+ return Optional.of(dtos.iterator().next());
+ }
+
+ public List<SnapshotDto> selectByUuids(DbSession dbSession, Collection<String> analysisUuids) {
+ return executeLargeInputs(analysisUuids, mapper(dbSession)::selectByUuids);
+ }
+
public Optional<SnapshotDto> selectLastAnalysisByComponentUuid(DbSession session, String componentUuid) {
return Optional.ofNullable(mapper(session).selectLastSnapshotByComponentUuid(componentUuid));
}
return snapshotDtos.isEmpty() ? null : snapshotDtos.get(0);
}
- public Optional<SnapshotDto> selectByUuid(DbSession dbSession, String analysisUuid) {
- return Optional.ofNullable(mapper(dbSession).selectByUuid(analysisUuid));
- }
-
public void switchIsLastFlagAndSetProcessedStatus(DbSession dbSession, String componentUuid, String analysisUuid) {
SnapshotMapper mapper = mapper(dbSession);
mapper.unsetIsLastFlagForComponentUuid(componentUuid);
List<SnapshotDto> selectByIds(@Param("ids") List<Long> ids);
+ List<SnapshotDto> selectByUuids(@Param("uuids") List<String> uuids);
+
void insert(SnapshotDto snapshot);
@CheckForNull
List<ViewsSnapshotDto> selectSnapshotBefore(@Param("componentUuid") String componentUuid, @Param("date") long date);
- @CheckForNull
- SnapshotDto selectByUuid(String analysisUuid);
-
void unsetIsLastFlagForComponentUuid(@Param("componentUuid") String componentUuid);
void setIsLastFlagForAnalysisUuid(@Param("analysisUuid") String analysisUuid);
</where>
</select>
- <select id="selectByUuid" parameterType="String" resultType="Snapshot">
+ <select id="selectByIds" parameterType="Long" resultType="Snapshot">
SELECT
- <include refid="snapshotColumns"/>
- FROM snapshots s
- WHERE s.uuid=#{uuid}
+ <include refid="snapshotColumns" />
+ FROM
+ snapshots s
+ WHERE
+ s.id in
+ <foreach collection="ids" item="id" separator="," open="(" close=")">
+ #{id}
+ </foreach>
</select>
- <select id="selectByIds" parameterType="Long" resultType="Snapshot">
+ <select id="selectByUuids" parameterType="List" resultType="Snapshot">
SELECT
- <include refid="snapshotColumns" />
- FROM snapshots s
+ <include refid="snapshotColumns"/>
+ FROM
+ snapshots s
WHERE
- s.id in
- <foreach collection="ids" item="id" separator="," open="(" close=")">
- #{id}
- </foreach>
+ s.uuid in
+ <foreach collection="uuids" item="uuid" separator="," open="(" close=")">
+ #{uuid}
+ </foreach>
</select>
<select id="selectLastSnapshotByComponentUuid" resultType="Snapshot">