Skip to content

Commit

Permalink
fix: query update
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Aug 16, 2023
1 parent 7d2fd5e commit 73c4462
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ public static AuthRecipeUserInfo[] getUsers(Start start, TenantIdentifier tenant
}, result -> {
List<UserInfoPaginationResultHolder> temp = new ArrayList<>();
while (result.next()) {
temp.add(new UserInfoPaginationResultHolder(result.getString("user_id"),
temp.add(new UserInfoPaginationResultHolder(result.getString("primary_or_recipe_user_id"),
result.getString("recipe_id")));
}
return temp;
Expand Down Expand Up @@ -959,11 +959,11 @@ public static AuthRecipeUserInfo[] getUsers(Start start, TenantIdentifier tenant
recipeIdCondition = recipeIdCondition + " AND";
}
String timeJoinedOrderSymbol = timeJoinedOrder.equals("ASC") ? ">" : "<";
String QUERY = "SELECT user_id, recipe_id FROM " + getConfig(start).getUsersTable() + " WHERE "
String QUERY = "SELECT primary_or_recipe_user_id, recipe_id FROM " + getConfig(start).getUsersTable() + " WHERE "
+ recipeIdCondition + " (time_joined " + timeJoinedOrderSymbol
+ " ? OR (time_joined = ? AND user_id <= ?)) AND app_id = ? AND tenant_id = ?"
+ " ? OR (time_joined = ? AND primary_or_recipe_user_id <= ?)) AND app_id = ? AND tenant_id = ?"
+ " ORDER BY time_joined " + timeJoinedOrder
+ ", user_id DESC LIMIT ?";
+ ", primary_or_recipe_user_id DESC LIMIT ?";
usersFromQuery = execute(start, QUERY, pst -> {
if (includeRecipeIds != null) {
for (int i = 0; i < includeRecipeIds.length; i++) {
Expand All @@ -981,19 +981,19 @@ public static AuthRecipeUserInfo[] getUsers(Start start, TenantIdentifier tenant
}, result -> {
List<UserInfoPaginationResultHolder> temp = new ArrayList<>();
while (result.next()) {
temp.add(new UserInfoPaginationResultHolder(result.getString("user_id"),
temp.add(new UserInfoPaginationResultHolder(result.getString("primary_or_recipe_user_id"),
result.getString("recipe_id")));
}
return temp;
});
} else {
String recipeIdCondition = RECIPE_ID_CONDITION.toString();
String QUERY = "SELECT user_id, recipe_id FROM " + getConfig(start).getUsersTable() + " WHERE ";
String QUERY = "SELECT primary_or_recipe_user_id, recipe_id FROM " + getConfig(start).getUsersTable() + " WHERE ";
if (!recipeIdCondition.equals("")) {
QUERY += recipeIdCondition + " AND";
}
QUERY += " app_id = ? AND tenant_id = ? ORDER BY time_joined " + timeJoinedOrder
+ ", user_id DESC LIMIT ?";
+ ", primary_or_recipe_user_id DESC LIMIT ?";
usersFromQuery = execute(start, QUERY, pst -> {
if (includeRecipeIds != null) {
for (int i = 0; i < includeRecipeIds.length; i++) {
Expand All @@ -1008,7 +1008,7 @@ public static AuthRecipeUserInfo[] getUsers(Start start, TenantIdentifier tenant
}, result -> {
List<UserInfoPaginationResultHolder> temp = new ArrayList<>();
while (result.next()) {
temp.add(new UserInfoPaginationResultHolder(result.getString("user_id"),
temp.add(new UserInfoPaginationResultHolder(result.getString("primary_or_recipe_user_id"),
result.getString("recipe_id")));
}
return temp;
Expand Down Expand Up @@ -1179,7 +1179,7 @@ private static AuthRecipeUserInfo[] listPrimaryUsersByEmailHelper(Start start, C
userIds);

// this is going to order them based on oldest that joined to newest that joined.
result.sort(Comparator.comparingLong(o -> o.timeJoined));
result.sort(Comparator.comparingLong(o -> o.timeJoined));

return result.toArray(new AuthRecipeUserInfo[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public void addPasswordResetTokenExceptions() throws Exception {
String pwHash = "fakehash";
String userEmail = "[email protected]";

var info = new PasswordResetTokenInfo(userId, tokenHash, System.currentTimeMillis() + 10000);
var info = new PasswordResetTokenInfo(userId, tokenHash, System.currentTimeMillis() + 10000, userEmail);
try {
storage.addPasswordResetToken(new AppIdentifier(null, null), info);
} catch (UnknownUserIdException ex) {
Expand Down

0 comments on commit 73c4462

Please sign in to comment.