Skip to content
Snippets Groups Projects
Commit 1abd5a47 authored by L. Ellenbeck's avatar L. Ellenbeck
Browse files

Fix: Removed role id from log call (coscine/issues#2001)

parent eeb77ffb
No related branches found
No related tags found
No related merge requests found
...@@ -34,7 +34,6 @@ namespace Coscine.Api.Admin.Controllers ...@@ -34,7 +34,6 @@ namespace Coscine.Api.Admin.Controllers
private readonly string _adminRole; private readonly string _adminRole;
private readonly ResourceModel _resourceModel; private readonly ResourceModel _resourceModel;
private readonly ProjectModel _projectModel; private readonly ProjectModel _projectModel;
private readonly ProjectRoleModel _projectRoleModel;
private readonly ProjectQuotaModel _projectQuotaModel; private readonly ProjectQuotaModel _projectQuotaModel;
private readonly ResourceTypeModel _resourceTypeModel; private readonly ResourceTypeModel _resourceTypeModel;
private readonly Emitter _emitter; private readonly Emitter _emitter;
...@@ -56,7 +55,6 @@ namespace Coscine.Api.Admin.Controllers ...@@ -56,7 +55,6 @@ namespace Coscine.Api.Admin.Controllers
_adminRole = "supportAdmin"; _adminRole = "supportAdmin";
_resourceModel = new ResourceModel(); _resourceModel = new ResourceModel();
_projectModel = new ProjectModel(); _projectModel = new ProjectModel();
_projectRoleModel = new ProjectRoleModel();
_projectQuotaModel = new ProjectQuotaModel(); _projectQuotaModel = new ProjectQuotaModel();
_resourceTypeModel = new ResourceTypeModel(); _resourceTypeModel = new ResourceTypeModel();
_emitter = new Emitter(Program.Configuration); _emitter = new Emitter(Program.Configuration);
...@@ -205,16 +203,17 @@ namespace Coscine.Api.Admin.Controllers ...@@ -205,16 +203,17 @@ namespace Coscine.Api.Admin.Controllers
if (Request.Query != null && Request.Query["noanalyticslog"] != "true") if (Request.Query != null && Request.Query["noanalyticslog"] != "true")
{ {
var project = _projectModel.GetById(projectQuota.ProjectId); LogAnalyticsAdminProjectQuotaChange(projectQuota.ProjectId, user);
LogAnalyticsAdminProjectQuotaChange(project, user);
} }
return NoContent(); return NoContent();
} }
private void LogAnalyticsAdminProjectQuotaChange(Project project, User user) private void LogAnalyticsAdminProjectQuotaChange(Guid projectId, User user)
{ {
var quotas = _projectQuotaModel.GetAllWhere(x => x.ProjectId == project.Id); try
{
var quotas = _projectQuotaModel.GetAllWhere(x => x.ProjectId == projectId);
var quotaObjects = quotas.Select(x => new ProjectQuotaObject var quotaObjects = quotas.Select(x => new ProjectQuotaObject
{ {
QuotaId = x.RelationId, QuotaId = x.RelationId,
...@@ -222,7 +221,7 @@ namespace Coscine.Api.Admin.Controllers ...@@ -222,7 +221,7 @@ namespace Coscine.Api.Admin.Controllers
Quota = x.Quota, Quota = x.Quota,
MaxQuota = x.MaxQuota, MaxQuota = x.MaxQuota,
Used = x.Quota, Used = x.Quota,
Allocated = CalculateAllocatedForAll(_resourceTypeModel.GetById(x.ResourceTypeId), project.Id) Allocated = CalculateAllocatedForAll(_resourceTypeModel.GetById(x.ResourceTypeId), projectId)
}).ToList(); }).ToList();
_coscineLogger.AnalyticsLog( _coscineLogger.AnalyticsLog(
...@@ -230,11 +229,16 @@ namespace Coscine.Api.Admin.Controllers ...@@ -230,11 +229,16 @@ namespace Coscine.Api.Admin.Controllers
{ {
Type = "Action", Type = "Action",
Operation = "Admin Project Quota Change", Operation = "Admin Project Quota Change",
RoleId = _projectRoleModel.GetGetUserRoleForProject(project.Id, user.Id).ToString(),
UserId = user.Id.ToString(), UserId = user.Id.ToString(),
ProjectId = project.Id.ToString(), ProjectId = projectId.ToString(),
QuotaSize = quotaObjects.ConvertAll(x => $"{x.ResourceType}: {x.Allocated}/{x.Used}") QuotaSize = quotaObjects.ConvertAll(x => $"{x.ResourceType}: {x.Allocated}/{x.Used}")
}); });
} }
#pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception.
catch (Exception)
#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception.
{
}
}
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment