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

EPMRPP-91771 organizations search improvement #1026

Merged
merged 2 commits into from
Aug 6, 2024
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 @@ -66,9 +66,16 @@
import static com.epam.ta.reportportal.commons.querygen.constant.LogCriteriaConstant.CRITERIA_LOG_PROJECT_ID;
import static com.epam.ta.reportportal.commons.querygen.constant.LogCriteriaConstant.CRITERIA_LOG_TIME;
import static com.epam.ta.reportportal.commons.querygen.constant.LogCriteriaConstant.CRITERIA_TEST_ITEM_ID;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_CREATED_DATE;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_CREATED_AT;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_ID;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_LAST_LAUNCH_RUN;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_LAUNCHES;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_NAME;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_PROJECTS;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_SLUG;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_TYPE;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_UPDATED_AT;
import static com.epam.ta.reportportal.commons.querygen.constant.OrganizationCriteriaConstant.CRITERIA_ORG_USERS;
import static com.epam.ta.reportportal.commons.querygen.constant.ProjectCriteriaConstant.CRITERIA_ALLOCATED_STORAGE;
import static com.epam.ta.reportportal.commons.querygen.constant.ProjectCriteriaConstant.CRITERIA_PROJECT_ATTRIBUTE_NAME;
import static com.epam.ta.reportportal.commons.querygen.constant.ProjectCriteriaConstant.CRITERIA_PROJECT_CREATION_DATE;
Expand Down Expand Up @@ -1413,26 +1420,23 @@ protected Field<Long> idField() {

ORGANIZATION_TARGET(OrganizationFilter.class, Arrays.asList(
new CriteriaHolderBuilder().newBuilder(CRITERIA_ID, ORGANIZATION.ID, Long.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_NAME, ORGANIZATION.NAME, String.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_SLUG, ORGANIZATION.SLUG, String.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_CREATED_DATE, ORGANIZATION.CREATED_AT,
new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_NAME, ORGANIZATION.NAME, String.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_SLUG, ORGANIZATION.SLUG, String.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_CREATED_AT, ORGANIZATION.CREATED_AT,
Timestamp.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_UPDATED_AT, ORGANIZATION.UPDATED_AT,
Timestamp.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_TYPE, ORGANIZATION.ORGANIZATION_TYPE,
String.class).get()
,
new CriteriaHolderBuilder().newBuilder(USERS_QUANTITY, USERS_QUANTITY, Long.class)
String.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_USERS, USERS_QUANTITY, Long.class)
.withAggregateCriteria(DSL.countDistinct(ORGANIZATION_USER.USER_ID).toString())
.get(),
new CriteriaHolderBuilder().newBuilder(PROJECTS_QUANTITY,
PROJECTS_QUANTITY,
Long.class)
new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_PROJECTS, PROJECTS_QUANTITY, Long.class)
.withAggregateCriteria(DSL.countDistinct(PROJECT.ID).toString()).get(),

new CriteriaHolderBuilder().newBuilder(LAST_RUN, LAST_RUN, Timestamp.class)
new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_LAST_LAUNCH_RUN, LAST_RUN, Timestamp.class)
.withAggregateCriteria(DSL.max(LAUNCH.START_TIME).toString())
.get(),

new CriteriaHolderBuilder().newBuilder(LAUNCHES_QUANTITY, LAUNCHES_QUANTITY, Long.class)
new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_LAUNCHES, LAUNCHES_QUANTITY, Long.class)
.withAggregateCriteria(
DSL.countDistinct(choose().when(LAUNCH.STATUS.ne(JStatusEnum.IN_PROGRESS), LAUNCH.ID))
.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@
public final class OrganizationCriteriaConstant {

public static final String CRITERIA_ORG_ID = "organization_id";
public static final String CRITERIA_ORG_TYPE = "organization_type";
public static final String CRITERIA_ORG_CREATED_DATE = "creation_date";
public static final String CRITERIA_ORG_NAME = "name";
public static final String CRITERIA_ORG_SLUG = "slug";
public static final String CRITERIA_ORG_TYPE = "type";
public static final String CRITERIA_ORG_CREATED_AT = "created_at";
public static final String CRITERIA_ORG_UPDATED_AT = "updated_at";
public static final String CRITERIA_ORG_USERS = "users";
public static final String CRITERIA_ORG_PROJECTS = "projects";
public static final String CRITERIA_ORG_LAUNCHES = "launches";
public static final String CRITERIA_ORG_LAST_LAUNCH_RUN = "last_launch_occurred";



private OrganizationCriteriaConstant() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ void organizationByFilterNotFound() {
@CsvSource(value = {
"slug|eq|my-organization|1",
"slug|eq|notexists|0",
"usersQuantity|eq|1|1",
"usersQuantity|eq|845|0",
"launchesQuantity|gt|-1|1",
"launchesQuantity|gt|999|0",
"projectsQuantity|eq|2|1",
"projectsQuantity|eq|999|0"
"users|eq|1|1",
"users|eq|845|0",
"launches|gt|-1|1",
"launches|gt|999|0",
"projects|eq|2|1",
"projects|eq|999|0"
}, delimiter = '|')
void findOrganizationByFilterWithUser(String field, String condition, String value, int rows) {
Filter filter = new Filter(OrganizationFilter.class,
Expand All @@ -100,16 +100,20 @@ void findOrganizationByFilterWithUser(String field, String condition, String val

@ParameterizedTest
@CsvSource(value = {
"name|eq|My organization|1",
"slug|eq|my-organization|1",
"slug|eq|notexists|0",
"usersQuantity|eq|2|1",
"usersQuantity|eq|845|0",
"launchesQuantity|gt|-1|1",
"launchesQuantity|gt|999|0",
"projectsQuantity|eq|2|1",
"projectsQuantity|eq|999|0",
"users|eq|2|1",
"users|eq|845|0",
"launches|gt|-1|1",
"launches|gt|999|0",
"projects|eq|2|1",
"projects|eq|999|0",
"user|eq|superadmin|1",
"user|eq|notexists|0"
"user|eq|notexists|0",
"created_at|gt|2024-08-01T12:42:30.758055Z|1",
"updated_at|gt|2024-08-01T12:42:30.758055Z|1",
"last_launch_occurred|lt|2024-08-01T12:42:30.758055Z|0"
}, delimiter = '|')
void findOrganizationByFilter(String field, String condition, String value, int rows) {
final List<OrganizationProfile> orgs = organizationRepositoryCustom.findByFilter(
Expand Down
Loading