Skip to content

Commit

Permalink
Fix/annoyance (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybeeelsdon authored Jul 25, 2024
1 parent c2be77a commit c7e69c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/DARE-API/Services/KeycloakMinioUserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ public async Task<bool> RemoveMinioUserAttribute(string accessToken, string user
throw;
}
}

public class MinioStuff{
public string username { get; set; }
public string id { get; set; }
}
public async Task<string> GetUserIDAsync(string accessToken, string userName)
{
var baseUrl = _submissionKeyCloakSettings.Server;
Expand All @@ -162,12 +167,12 @@ public async Task<string> GetUserIDAsync(string accessToken, string userName)
try
{

var jsonObject = JsonConvert.DeserializeObject<JArray>(jsonString);
var jsonObject = JsonConvert.DeserializeObject<List<MinioStuff>>(jsonString);
foreach (var item in jsonObject)
{
if (item["username"].ToString().ToLower() == userName.ToLower())
if (item.username.ToString().ToLower() == userName.ToLower())
{
return item["id"].ToString();
return item.id.ToString();
}
}

Expand Down
12 changes: 7 additions & 5 deletions src/DARE-FrontEnd/Controllers/ProjectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@ public async Task<IActionResult> GetProject(int id)
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
await projectawait;
Log.Error("projectawait took ElapsedMilliseconds" + stopwatch.ElapsedMilliseconds);
//Log.Error("projectawait took ElapsedMilliseconds" + stopwatch.ElapsedMilliseconds);
await minioEndpoint;
Log.Error("minioEndpoint took ElapsedMilliseconds" + stopwatch.ElapsedMilliseconds);
//Log.Error("minioEndpoint took ElapsedMilliseconds" + stopwatch.ElapsedMilliseconds);
stopwatch.Stop();
var project = projectawait.Result;
var users = _clientHelper.CallAPIWithoutModel<List<BL.Models.User>>("/api/User/GetAllUsers/").Result;
var tres = _clientHelper.CallAPIWithoutModel<List<Tre>>("/api/Tre/GetAllTres/").Result;

var userItems2 = project.Users;
var treItems2 = project.Tres;
var userItems2 = users.Where(p => !project.Users.Select(x => x.Id).Contains(p.Id)).ToList();
var treItems2 = tres.Where(p => !project.Tres.Select(x => x.Id).Contains(p.Id)).ToList();

var userItems = userItems2
.Select(p => new SelectListItem { Value = p.Id.ToString(), Text = p.FullName != "" ? p.FullName : p.Name })
Expand Down Expand Up @@ -126,7 +128,7 @@ public async Task<IActionResult> GetProject(int id)
TreItemList = treItems
};

Log.Error("View(projectView) took ElapsedMilliseconds" + stopwatch.ElapsedMilliseconds);
//Log.Error("View(projectView) took ElapsedMilliseconds" + stopwatch.ElapsedMilliseconds);
return View(projectView);
}

Expand Down

0 comments on commit c7e69c6

Please sign in to comment.