Skip to content

Commit

Permalink
fix: bug in dashboard search query (#73)
Browse files Browse the repository at this point in the history
* fix: bug in dashboard search query

* updates CHANGELOG and version info

* reverts unnecessary changes
  • Loading branch information
jscyo authored Mar 31, 2023
1 parent 8e67f85 commit ecf01f1
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public static AuthRecipeUserInfo[] getUsers(Start start, @NotNull Integer limit,
// check if email tag is present
if (dashboardSearchTags.emails != null) {

QUERY += " WHERE thirdPartyTable.email LIKE ? OR thirdPartyTable.email LIKE ?";
QUERY += " WHERE ( thirdPartyTable.email LIKE ? OR thirdPartyTable.email LIKE ?";
queryList.add(dashboardSearchTags.emails.get(0) + "%");
queryList.add("%@" + dashboardSearchTags.emails.get(0) + "%");

Expand All @@ -452,6 +452,8 @@ public static AuthRecipeUserInfo[] getUsers(Start start, @NotNull Integer limit,
queryList.add("%@" + dashboardSearchTags.emails.get(i) + "%");
}

QUERY += " )";

}

// check if providers tag is present
Expand All @@ -462,12 +464,14 @@ public static AuthRecipeUserInfo[] getUsers(Start start, @NotNull Integer limit,
QUERY += " WHERE ";
}

QUERY += " thirdPartyTable.third_party_id LIKE ?";
QUERY += " ( thirdPartyTable.third_party_id LIKE ?";
queryList.add(dashboardSearchTags.providers.get(0) + "%");
for (int i = 1; i < dashboardSearchTags.providers.size(); i++) {
QUERY += " OR thirdPartyTable.third_party_id LIKE ?";
queryList.add(dashboardSearchTags.providers.get(i) + "%");
}

QUERY += " )";
}

// check if we need to append this to an existing search query
Expand All @@ -493,14 +497,16 @@ public static AuthRecipeUserInfo[] getUsers(Start start, @NotNull Integer limit,
// check if email tag is present
if (dashboardSearchTags.emails != null) {

QUERY = QUERY + " WHERE passwordlessTable.email LIKE ? OR passwordlessTable.email LIKE ?";
QUERY = QUERY + " WHERE ( passwordlessTable.email LIKE ? OR passwordlessTable.email LIKE ?";
queryList.add(dashboardSearchTags.emails.get(0) + "%");
queryList.add("%@" + dashboardSearchTags.emails.get(0) + "%");
for (int i = 1; i < dashboardSearchTags.emails.size(); i++) {
QUERY += " OR passwordlessTable.email LIKE ? OR passwordlessTable.email LIKE ?";
queryList.add(dashboardSearchTags.emails.get(i) + "%");
queryList.add("%@" + dashboardSearchTags.emails.get(i) + "%");
}

QUERY += " )";
}

// check if phone tag is present
Expand All @@ -512,20 +518,14 @@ public static AuthRecipeUserInfo[] getUsers(Start start, @NotNull Integer limit,
QUERY += " WHERE ";
}

QUERY += " passwordlessTable.phone_number LIKE ?";
if (dashboardSearchTags.phoneNumbers.get(0).startsWith("+")) {
queryList.add(dashboardSearchTags.phoneNumbers.get(0) + "%");
} else {
queryList.add("+" + dashboardSearchTags.phoneNumbers.get(0) + "%");
}
QUERY += " ( passwordlessTable.phone_number LIKE ?";
queryList.add(dashboardSearchTags.phoneNumbers.get(0) + "%");
for (int i = 1; i < dashboardSearchTags.phoneNumbers.size(); i++) {
QUERY += " OR passwordlessTable.phone_number LIKE ?";
if (dashboardSearchTags.phoneNumbers.get(i).startsWith("+")) {
queryList.add(dashboardSearchTags.phoneNumbers.get(i) + "%");
} else {
queryList.add("+" + dashboardSearchTags.phoneNumbers.get(i) + "%");
}
queryList.add(dashboardSearchTags.phoneNumbers.get(i) + "%");
}

QUERY += " )";
}

// check if we need to append this to an existing search query
Expand Down

0 comments on commit ecf01f1

Please sign in to comment.