Skip to content

Commit

Permalink
Merge pull request #955 from reportportal/EPMRPP-87813
Browse files Browse the repository at this point in the history
EPMRPP-87813 || Send to the analyzer the id of previous launch
  • Loading branch information
APiankouski authored Nov 23, 2023
2 parents a24202c + ae1098e commit 8eebe6f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,6 @@ boolean hasItemsWithLogsWithLogLevel(Long launchId, Collection<JTestItemTypeEnum
Optional<Launch> findPreviousLaunchByProjectIdAndNameAndAttributesForLaunchIdAndModeNot(
Long projectId, String name, String[] attributes, Long launchId, JLaunchModeEnum mode
);

Optional<Long> findPreviousLaunchId(Launch launch);
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
import java.util.stream.Collectors;
import org.jooq.DSLContext;
import org.jooq.Field;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.SelectSeekStep1;
import org.jooq.SortField;
import org.jooq.impl.DSL;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -404,4 +407,17 @@ public Optional<Launch> findPreviousLaunchByProjectIdAndNameAndAttributesForLaun
.limit(1)
.fetchOptionalInto(Launch.class);
}

public Optional<Long> findPreviousLaunchId(Launch launch) {
return dsl
.select(LAUNCH.ID)
.from(LAUNCH)
.where(LAUNCH.ID.ne(launch.getId())
.and(LAUNCH.NAME.eq(launch.getName()))
.and(LAUNCH.NUMBER.lt(launch.getNumber().intValue())
.and(LAUNCH.PROJECT_ID.eq(launch.getProjectId()))))
.orderBy(LAUNCH.NUMBER.desc())
.limit(1)
.fetchOptionalInto(Long.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public enum AnalyzeMode {
BY_LAUNCH_NAME("LAUNCH_NAME"),
CURRENT_LAUNCH("CURRENT_LAUNCH"),
PREVIOUS_LAUNCH("PREVIOUS_LAUNCH"),

CURRENT_AND_THE_SAME_NAME("CURRENT_AND_THE_SAME_NAME");

private String value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.epam.ta.reportportal.commons.querygen.FilterCondition;
import com.epam.ta.reportportal.entity.enums.LaunchModeEnum;
import com.epam.ta.reportportal.entity.enums.StatusEnum;
import com.epam.ta.reportportal.entity.item.TestItem;
import com.epam.ta.reportportal.entity.launch.Launch;
import com.epam.ta.reportportal.jooq.enums.JLaunchModeEnum;
import com.epam.ta.reportportal.jooq.enums.JStatusEnum;
Expand Down Expand Up @@ -445,6 +446,18 @@ void shouldNotFindLaunchesWithSystemAttributes() {
assertTrue(launches.isEmpty());
}

@Test
void findPreviousLaunchId() {
Launch launch = new Launch();
launch.setName("finished launch");
launch.setId(300L);
launch.setProjectId(2L);
launch.setNumber(3L);
Optional<Long> previousLaunchId = launchRepository.findPreviousLaunchId(launch);

assertEquals(200L, previousLaunchId.orElse(0L));
}

private Filter buildDefaultFilter(Long projectId) {
List<ConvertibleCondition> conditionList = Lists.newArrayList(
new FilterCondition(Condition.EQUALS,
Expand Down

0 comments on commit 8eebe6f

Please sign in to comment.