-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[PM-19145] refactor organization service.import async #5800
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
Open
BTreston
wants to merge
30
commits into
main
Choose a base branch
from
ac/pm-19145-refactor-OrganizationService.ImportAsync
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+605
โ384
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ad1b78d
initial lift and shift
BTreston eec8b76
extract function RemoveExistingExternalUsers
BTreston 5582f25
Extract function RemoveExistingUsers()
BTreston 2f4574f
extract function OverwriteExisting()
BTreston 9801c63
create new model for sync data
BTreston 1f5ea44
extract add users to function, rename
BTreston f47a65c
rename OrganizatinUserInvite for command, implement command
BTreston f76d6fd
implement command
BTreston 15cff6c
refactor groups logic
BTreston 99e405a
fix imports
BTreston 0a2e8e5
remove old tests, fix imports
BTreston 5b09101
Merge branch 'main' into ac/pm-19145-refactor-OrganizationService.Impโฆ
BTreston fcf7bd8
fix namespace
BTreston be8bd57
fix CommandResult useage
BTreston 31b7dcd
tests wip
BTreston 04383a8
wip
BTreston 2cac1c8
wip
BTreston be23fe6
remove redundant code, remove looping db call, refactor tests
BTreston 3ae9fbd
clean up
BTreston 57e035b
remove looping db call with bulk method
BTreston da7c961
clean up
BTreston 94fc71e
remove orgId param to use id already in request
BTreston af11c07
change param
BTreston f6035d8
cleanup params
BTreston 5a78067
Merge branch 'main' into ac/pm-19145-refactor-OrganizationService.Impโฆ
BTreston 7db1129
remove IReferenceEventService
BTreston ea02dfb
fix test
BTreston 36879fe
fix tests
BTreston 4af676e
cr feedback
BTreston 7994f61
remove _timeProvider
BTreston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/Core/AdminConsole/Models/Data/Organizations/OrganizationGroupImportData.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
๏ปฟusing Bit.Core.AdminConsole.Entities; | ||
using Bit.Core.AdminConsole.Models.Business; | ||
|
||
namespace Bit.Core.Models.Data.Organizations; | ||
|
||
public class OrganizationGroupImportData | ||
{ | ||
public IEnumerable<ImportedGroup> Groups { get; init; } | ||
public ICollection<Group> ExistingGroups { get; init; } | ||
public IEnumerable<Group> ExistingExternalGroups { get; init; } | ||
public IDictionary<string, ImportedGroup> GroupsDict { get; init; } | ||
|
||
public OrganizationGroupImportData(IEnumerable<ImportedGroup> groups, ICollection<Group> existingGroups) | ||
{ | ||
Groups = groups; | ||
GroupsDict = groups.ToDictionary(g => g.Group.ExternalId); | ||
ExistingGroups = existingGroups; | ||
ExistingExternalGroups = GetExistingExternalGroups(existingGroups); | ||
} | ||
|
||
private IEnumerable<Group> GetExistingExternalGroups(ICollection<Group> existingGroups) | ||
{ | ||
return existingGroups | ||
.Where(u => !string.IsNullOrWhiteSpace(u.ExternalId)) | ||
.ToList(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...re/AdminConsole/Models/Data/Organizations/OrganizationUsers/OrganizationUserImportData.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
๏ปฟnamespace Bit.Core.Models.Data.Organizations.OrganizationUsers; | ||
|
||
public class OrganizationUserImportData | ||
{ | ||
public HashSet<string> NewUsersSet { get; init; } | ||
public ICollection<OrganizationUserUserDetails> ExistingUsers { get; init; } | ||
public IEnumerable<OrganizationUserUserDetails> ExistingExternalUsers { get; init; } | ||
public Dictionary<string, Guid> ExistingExternalUsersIdDict { get; init; } | ||
|
||
public OrganizationUserImportData(ICollection<OrganizationUserUserDetails> existingUsers, HashSet<string> newUsersSet) | ||
{ | ||
NewUsersSet = newUsersSet; | ||
ExistingUsers = existingUsers; | ||
ExistingExternalUsers = GetExistingExternalUsers(existingUsers); | ||
ExistingExternalUsersIdDict = GetExistingExternalUsers(existingUsers).ToDictionary(u => u.ExternalId, u => u.Id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is calling ExistingExternalUsers = GetExistingExternalUsers(existingUsers);
ExistingExternalUsersIdDict = ExistingExternalUsers.ToDictionary(u => u.ExternalId, u => u.Id); |
||
} | ||
|
||
private IEnumerable<OrganizationUserUserDetails> GetExistingExternalUsers(ICollection<OrganizationUserUserDetails> existingUsers) | ||
{ | ||
return existingUsers | ||
.Where(u => !string.IsNullOrWhiteSpace(u.ExternalId)) | ||
.ToList(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these all can/should be
readonly
. xmldoc would also be really useful (e.g.HashSet<string>
is pretty vague)