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

fix: remove con reuse #150

Merged
merged 5 commits into from
Sep 6, 2023
Merged

fix: remove con reuse #150

merged 5 commits into from
Sep 6, 2023

Conversation

sattvikc
Copy link
Collaborator

@sattvikc sattvikc commented Sep 2, 2023

Summary of change

(A few sentences about this PR)

Related issues

  • Link to issue1 here
  • Link to issue1 here

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)

Documentation changes

(If relevant, please create a PR in our docs repo, or create a checklist here highlighting the necessary changes)

Checklist for important updates

  • Changelog has been updated
  • pluginInterfaceSupported.json file has been updated (if needed)
  • Changes to the version if needed
    • In build.gradle
  • Had installed and ran the pre-commit hook
  • If there are new dependencies that have been added in build.gradle, please make sure to add them in implementationDependencies.json.
  • Issue this PR against the latest non released version branch.
    • To know which one it is, run find the latest released tag (git tag) in the format vX.Y.Z, and then find the latest branch (git branch --all) whose X.Y is greater than the latest released tag.
    • If no such branch exists, then create one from the latest released branch.

Remaining TODOs for this PR

  • Item1
  • Item2

@sattvikc sattvikc self-assigned this Sep 2, 2023
Comment on lines 419 to 420
fillUserInfoWithTenantIds_transaction(start, con, appIdentifier, userInfos);
fillUserInfoWithVerified_transaction(start, con, appIdentifier, userInfos);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split them also into without transaction

@@ -449,7 +483,7 @@ public static String getPrimaryUserIdUsingEmail(Start start, Connection con, Ten
" ON ep.app_id = all_users.app_id AND ep.user_id = all_users.user_id" +
" WHERE ep.app_id = ? AND ep.tenant_id = ? AND ep.email = ?";

return execute(con, QUERY, pst -> {
return execute(start, QUERY, pst -> {
pst.setString(1, tenantIdentifier.getAppId());
pst.setString(2, tenantIdentifier.getTenantId());
pst.setString(3, email);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a function getPrimaryUserIdsUsingEmail right below which should be renamed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Search in the file for "Connection" and see that the function name has a _Transaction

}

public static AuthRecipeUserInfo[] listPrimaryUsersByEmailHelper(Start start, Connection con,
public static AuthRecipeUserInfo[] listPrimaryUsersByEmailHelper(Start start,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this function is just used once, then rename it to listPrimaryUsersByEmail


// remove duplicates from userIds
Set<String> userIdsSet = new HashSet<>(userIds);
userIds = new ArrayList<>(userIdsSet);

List<AuthRecipeUserInfo> result = getPrimaryUserInfoForUserIds(start, con, tenantIdentifier.toAppIdentifier(),
List<AuthRecipeUserInfo> result = getPrimaryUserInfoForUserIds(start, tenantIdentifier.toAppIdentifier(),
userIds);

// this is going to order them based on oldest that joined to newest that joined.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename listPrimaryUsersByEmailHelper below to have transaction in the name

}

private static AuthRecipeUserInfo[] listPrimaryUsersByThirdPartyInfoHelper(Start start, Connection con,
private static AuthRecipeUserInfo[] listPrimaryUsersByThirdPartyInfoHelper(Start start,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is only used in one place, rename this to the actual func name

// which is linked to a primary user ID in which case it won't be in the primary_or_recipe_user_id column,
// or the input may have a primary user ID whose recipe user ID was removed, so it won't be in the user_id
// column
String QUERY = "SELECT * FROM " + getConfig(start).getUsersTable() +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if this requires for update or not

finalResult.add(UserInfoRowMapper.getInstance().mapOrThrow(result));
}
return finalResult;
});
fillUserInfoWithTenantIds_transaction(start, con, appIdentifier, userInfos);
fillUserInfoWithVerified_transaction(start, con, appIdentifier, userInfos);
return userInfos.stream().map(UserInfoPartial::toLoginMethod).collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename function below (getUserById) to have transaction

@sattvikc sattvikc merged commit b5a3c9a into feat/account-linking Sep 6, 2023
1 of 3 checks passed
@sattvikc sattvikc deleted the al-test-fixes branch September 6, 2023 11:02
rishabhpoddar added a commit that referenced this pull request Sep 20, 2023
* up to speed iwth in mem db

* bug fix

* adds link account function

* removes unneeded index

* Account linking function changes (#136)

* fixes bugs

* more tests

* Link accounts (#137)

* fixes bugs

* more tests

* updates to function (#138)

* Account linking unlink accounts (#139)

* updates to function

* adds unlink account function

* fixes and adds test (#140)

* changes for password reset flow (#141)

* Account linking update email (#142)

* changes for password reset flow

* removes unneeded function

* removes unneeded function

* adds recipe user id in session (#143)

* fixes query (#144)

* fix: user pagination (#145)

* fix: query update

* fix: primary_or_recipe_user_time_joined added to all_auth_users table

* fix: primary_or_recipe_user_time_joined added to all_auth_users table

* fix: user pagination queries

* fix: user pagination queries

* fix: plugin interface fix (#146)

* fix: plugin interface fix

* fix: pr comments

* fix: pr comments

* fix: External userid (#147)

* fix: plugin interface fix

* fix: pr comments

* fix: pr comments

* fix: external userid

* fix: remove UserInfo class (#148)

* fix: multitenant user association with account linking (#149)

* fix: tenant association query fixes

* fix: multitenancy related changes

* fix: pr comments

* fix: pr comments

* fix: pr comments

* fix: remove con reuse (#150)

* fix: remove con reuse

* fix: pr comments

* fix: pr comments

* fix: pr comments

* fix: pr comments

* fix: index updates (#152)

* fix: updated indexes

* fix: pr comments

* fix: pr comments

* fix: fkey constraint for primary_or_recipe_user_id (#153)

* fix: account linking stats (#154)

* fix: account linking stats

* fix: query

* fix: pr comment

* fix: fixing tenant association

* fix: allow user disassociation from all tenant (#156)

* fix: allow user disassociation from all tenant

* fix: query

* fix: useridmapping functions (#157)

* fix: version and changelog

* fix: version and changelog

* fix: time joined fix

---------

Co-authored-by: rishabhpoddar <rishabh.poddar@gmail.com>
Co-authored-by: Mihály Lengyel <mihaly@lengyel.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants