Skip to content

Commit

Permalink
Changed Score and JaccardIndex to include users that has the access a…
Browse files Browse the repository at this point in the history
…s extra, but not the role.
  • Loading branch information
Dany Gonzalez-Teigland authored and ragnarstolsmark committed Nov 7, 2024
1 parent 9745671 commit 2b8e14b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 4 additions & 5 deletions RoleMining.Library/Algorithms/JaccardIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ public List<Score> CalculateScores(IEnumerable<UserAccess> userAccesses, IEnumer
var userAccessValidator = new UserAccessValidator();
var userInRoleValidator = new UserInRoleValidator();

// TODO: Move validation outside of the method
userAccessValidator.ValidateAndThrowArgumentExceptions(userAccesses, nameof(userAccesses));
userInRoleValidator.ValidateAndThrowArgumentExceptions(userInRoles, nameof(userInRoles));


// Bad data handling
// To be implented

// Access -> Users
var accessesWithListOfUsers = userAccesses.GroupBy(uA => uA.AccessID)
.ToDictionary(group => group.Key, group => new HashSet<string>(group.Select(uA => uA.UserID).ToList()));
Expand Down Expand Up @@ -100,9 +97,11 @@ public List<Score> CalculateScores(IEnumerable<UserAccess> userAccesses, IEnumer
RoleID = roleID,
AccessID = accessID,
UsersWithAccessAndRoleCount = usersWithRoleAndExtraAccess,
UsersWithAccessWithoutRoleCount = usersWithExtraAccess.Count() - usersWithRoleAndExtraAccess,
UsersWithoutAccessWithRoleCount = usersWithRole.Count() - usersWithRoleAndExtraAccess,
UsersWithAccessAndRole = usersWithRole.Intersect(usersWithExtraAccess).OrderBy(u => u).ToList(),
UsersWithoutAccessWithRole = usersWithRole.Except(usersWithExtraAccess).OrderBy(u => u).ToList()
UsersWithoutAccessWithRole = usersWithRole.Except(usersWithExtraAccess).OrderBy(u => u).ToList(),
UsersWithAccessWithoutRole = usersWithExtraAccess.Except(usersWithRole).OrderBy(u => u).ToList()
});
}
}
Expand Down
10 changes: 10 additions & 0 deletions RoleMining.Library/Classes/Score.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public class Score
/// </summary>
public int UsersWithAccessAndRoleCount { get; set; }

/// <summary>
/// Amount of users with the access, but not with the role
/// </summary>
public int UsersWithAccessWithoutRoleCount { get; set; }

/// <summary>
/// Amount of users with the role, but not with the access
/// </summary>
Expand All @@ -37,6 +42,11 @@ public class Score
/// </summary>
public List<string> UsersWithAccessAndRole { get; set; }

/// <summary>
/// List of userIDs with the access, but not with the role
/// </summary>
public List<string> UsersWithAccessWithoutRole { get; set; }

/// <summary>
/// List of UserIDs with the role, but not with the access
/// </summary>
Expand Down

0 comments on commit 2b8e14b

Please sign in to comment.