Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return latest while resolving affected libraries #442

Merged
merged 2 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -433,25 +433,24 @@ Boolean isBugLibIdAffected(
*/
@Query(
value =
" select * from (select distinct * from"
+ " bug_affected_library where source='MANUAL' and lib is null UNION select"
+ " distinct * from bug_affected_library as al1"
+ " where al1.lib is null and (al1.source='KAYBEE') and not exists (select 1 from"
" select * from (select distinct * from bug_affected_library where source='MANUAL' and"
+ " lib is null UNION select distinct * from bug_affected_library as al1 where"
+ " al1.lib is null and (al1.source='KAYBEE') and not exists (select 1 from"
+ " bug_affected_library as al2 where al2.source='MANUAL' and al1.bug_id=al2.bug_id"
+ " and al1.library_id=al2.library_id) UNION select distinct"
+ " * from bug_affected_library as al1 where"
+ " al1.lib is null and (al1.source='CHECK_CODE') and not exists (select 1 from"
+ " bug_affected_library as al2 where (al2.source='MANUAL' or al2.source='KAYBEE')"
+ " and al1.bug_id=al2.bug_id and al1.library_id=al2.library_id) UNION select"
+ " distinct * from bug_affected_library as al1"
+ " where al1.lib is null and (al1.source='AST_EQUALITY' OR"
+ " al1.source='MINOR_EQUALITY'OR al1.source='MAJOR_EQUALITY' OR"
+ " and al1.library_id=al2.library_id) UNION select distinct * from"
+ " bug_affected_library as al1 where al1.lib is null and (al1.source='CHECK_CODE') "
+ " and not exists (select 1 from bug_affected_library as al2 where"
+ " (al2.source='MANUAL' or al2.source='KAYBEE') and al1.bug_id=al2.bug_id and"
+ " al1.library_id=al2.library_id) UNION select distinct * from"
+ " bug_affected_library as al1 where al1.lib is null and (al1.source='AST_EQUALITY'"
+ " OR al1.source='MINOR_EQUALITY'OR al1.source='MAJOR_EQUALITY' OR"
+ " al1.source='GREATER_RELEASE' OR al1.source='INTERSECTION' OR"
+ " al1.source='PROPAGATE_MANUAL') and not exists (select 1 from"
+ " bug_affected_library as al2 where (al2.source='MANUAL' OR"
+ " al2.source='CHECK_CODE' OR al2.source='KAYBEE') and al1.bug_id=al2.bug_id and"
+ " al1.library_id=al2.library_id)) as a where a.bug_id=:bug_id and"
+ " a.library_id=:library_id",
+ " al1.source='PROPAGATE_MANUAL') and al1.created_at=(select max(created_at) from"
+ " bug_affected_library where bug_id=:bug_id and library_id=:library_id and not"
+ " source='TO_REVIEW') and not exists (select 1 from bug_affected_library as al2"
+ " where (al2.source='MANUAL' OR al2.source='CHECK_CODE' OR al2.source='KAYBEE')"
+ " and al1.bug_id=al2.bug_id and al1.library_id=al2.library_id)) as a where"
+ " a.bug_id=:bug_id and a.library_id=:library_id",
nativeQuery = true)
AffectedLibrary findResolvedAffectedLibrary(
@Param("bug_id") String bug_id, @Param("library_id") LibraryId library_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,14 +706,18 @@ public void testGetResolvedAffectedLibrary() throws Exception {
AffectedLibrary afflib2_ast = new AffectedLibrary(bug, lid2, false, null, null, null);
afflib2_ast.setSource(AffectedVersionSource.AST_EQUALITY);

AffectedLibrary afflib2_intersection = new AffectedLibrary(bug, lid2, true, null, null, null);
afflib2_intersection.setSource(AffectedVersionSource.INTERSECTION);

AffectedLibrary afflib3 = new AffectedLibrary(bug, lid3, null, null, null, null);
afflib3.setSource(AffectedVersionSource.TO_REVIEW);

AffectedLibrary[] afflibs = new AffectedLibrary[4];
AffectedLibrary[] afflibs = new AffectedLibrary[5];
afflibs[0] = afflib1;
afflibs[1] = afflib2;
afflibs[2] = afflib2_ast;
afflibs[3] = afflib3;
afflibs[3] = afflib2_intersection;
afflibs[4] = afflib3;
afflibRepository.customSave(bug, afflibs);

final MockHttpServletRequestBuilder get_builder =
Expand All @@ -728,7 +732,7 @@ public void testGetResolvedAffectedLibrary() throws Exception {
.perform(get("/bugs/" + bug.getBugId() + "/affectedLibIds"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$.length()", is(4)));
.andExpect(jsonPath("$.length()", is(5)));
}

/*@Test
Expand Down