Skip to content

Commit 2b8e14b

Browse files
Dany Gonzalez-Teiglandragnarstolsmark
authored andcommitted
Changed Score and JaccardIndex to include users that has the access as extra, but not the role.
1 parent 9745671 commit 2b8e14b

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

RoleMining.Library/Algorithms/JaccardIndex.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@ public List<Score> CalculateScores(IEnumerable<UserAccess> userAccesses, IEnumer
2121
var userAccessValidator = new UserAccessValidator();
2222
var userInRoleValidator = new UserInRoleValidator();
2323

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

27-
28-
// Bad data handling
29-
// To be implented
30-
3128
// Access -> Users
3229
var accessesWithListOfUsers = userAccesses.GroupBy(uA => uA.AccessID)
3330
.ToDictionary(group => group.Key, group => new HashSet<string>(group.Select(uA => uA.UserID).ToList()));
@@ -100,9 +97,11 @@ public List<Score> CalculateScores(IEnumerable<UserAccess> userAccesses, IEnumer
10097
RoleID = roleID,
10198
AccessID = accessID,
10299
UsersWithAccessAndRoleCount = usersWithRoleAndExtraAccess,
100+
UsersWithAccessWithoutRoleCount = usersWithExtraAccess.Count() - usersWithRoleAndExtraAccess,
103101
UsersWithoutAccessWithRoleCount = usersWithRole.Count() - usersWithRoleAndExtraAccess,
104102
UsersWithAccessAndRole = usersWithRole.Intersect(usersWithExtraAccess).OrderBy(u => u).ToList(),
105-
UsersWithoutAccessWithRole = usersWithRole.Except(usersWithExtraAccess).OrderBy(u => u).ToList()
103+
UsersWithoutAccessWithRole = usersWithRole.Except(usersWithExtraAccess).OrderBy(u => u).ToList(),
104+
UsersWithAccessWithoutRole = usersWithExtraAccess.Except(usersWithRole).OrderBy(u => u).ToList()
106105
});
107106
}
108107
}

RoleMining.Library/Classes/Score.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public class Score
2727
/// </summary>
2828
public int UsersWithAccessAndRoleCount { get; set; }
2929

30+
/// <summary>
31+
/// Amount of users with the access, but not with the role
32+
/// </summary>
33+
public int UsersWithAccessWithoutRoleCount { get; set; }
34+
3035
/// <summary>
3136
/// Amount of users with the role, but not with the access
3237
/// </summary>
@@ -37,6 +42,11 @@ public class Score
3742
/// </summary>
3843
public List<string> UsersWithAccessAndRole { get; set; }
3944

45+
/// <summary>
46+
/// List of userIDs with the access, but not with the role
47+
/// </summary>
48+
public List<string> UsersWithAccessWithoutRole { get; set; }
49+
4050
/// <summary>
4151
/// List of UserIDs with the role, but not with the access
4252
/// </summary>

0 commit comments

Comments
 (0)