Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • Fix/xxxx-resourceVisibility
  • Hotfix/1357-ymlFile
  • Hotfix/1370-swaggerDescription
  • Hotfix/2077-fixSupportAdminLog
  • Hotfix/2087-efNet6
  • Hotfix/2224-quotaSizeAnalytics
  • Hotfix/2427-adminTrouble
  • Hotfix/82-updateDepsOfAPIs
  • Issue/1866-ExtendResourceTypeConfigurationTUDo
  • Issue/1877-ExtendResourceTypeConfigurationNRWFHs
  • Issue/1910-MigrationtoNET6.0
  • Issue/1940ResouceKeysForNRWAndTUDO
  • Issue/1951-quotaImplementation
  • Issue/2001-extendAnalyticsLogger
  • Issue/2061-activateResourceTypeRdss3nrw
  • Issue/2072-wormResourceType
  • Issue/2309-docs
  • Issue/2330-fixNaNQuotainAdmin
  • Product/1119-quotaAdminPage
  • Product/1287-dotnet5Sharepoint
  • Product/1559-rdsS3QuotaManagement
  • Product/1600-rdsS3QuotaManagement
  • Product/1623-allocatedQuotaForAdmin
  • Sprint/2020-22
  • Sprint/2021-03
  • Sprint/2021-05
  • Sprint/2021-08
  • Sprint/2021-13
  • Sprint/2021-17
  • Sprint/2021-23
  • Sprint/2022-01
  • Sprint/2022-05
  • Topic/1163-adminApi
  • Topic/1335-dotnet5Apis
  • Topic/1568-quotaApiAdjustments
  • Topic/1688-allocatedQuotaForAdminApi
  • dev
  • gitkeep
  • master
  • v1.1.0
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.0.3
  • v2.1.0
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.4.0
  • v2.5.0
  • v2.5.1
  • v2.5.2
  • v2.5.3
  • v2.5.4
  • v2.6.0
  • v2.6.1
  • v3.0.0
  • v3.0.1
  • v3.0.2
  • v3.0.3
  • v3.0.4
  • v3.0.5
  • v3.0.6
  • v3.0.7
  • v3.0.8
68 results

Target

Select target project
  • coscine/backend/apis/admin
1 result
Select Git revision
Show changes
Commits on Source (3)
......@@ -5,7 +5,7 @@
<AssemblyName>Coscine.Api.Admin</AssemblyName>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFramework>net6.0</TargetFramework>
<Version>2.5.4</Version>
<Version>2.6.0</Version>
</PropertyGroup>
<PropertyGroup>
<Authors>RWTH Aachen University</Authors>
......@@ -21,6 +21,6 @@
<PackageReference Include="Coscine.ApiCommons" Version="2.*-*" />
<PackageReference Include="Coscine.Database" Version="2.*-*" />
<PackageReference Include="Coscine.Metadata" Version="2.*-*" />
<PackageReference Include="Coscine.ResourceLoader" Version="2.*-*" />
<PackageReference Include="Coscine.ResourceTypes" Version="*-*" />
</ItemGroup>
</Project>
......@@ -8,7 +8,7 @@ using Coscine.Database.DataModel;
using Coscine.Database.Models;
using Coscine.Logging;
using Coscine.Metadata;
using Coscine.ResourceLoader;
using Coscine.ResourceTypes;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
......@@ -25,7 +25,6 @@ namespace Coscine.Api.Admin.Controllers
{
private readonly RdfStoreConnector _rdfStoreConnector = new(Program.Configuration.GetStringAndWait("coscine/local/virtuoso/additional/url"));
private readonly Authenticator _authenticator;
private readonly IConfiguration _configuration;
private readonly string _graphUrl;
private readonly string _memberUrl;
private readonly string _userUrlPrefix;
......@@ -46,7 +45,6 @@ namespace Coscine.Api.Admin.Controllers
public AdminController(ILogger<AdminController> logger)
{
_authenticator = new Authenticator(this, Program.Configuration);
_configuration = Program.Configuration;
_graphUrl = "https://ror.org/04xfq0f34/roles";
_memberUrl = "http://www.w3.org/ns/org#member";
_userUrlPrefix = "https://coscine.rwth-aachen.de/u/";
......@@ -94,14 +92,18 @@ namespace Coscine.Api.Admin.Controllers
/// <returns>Allocated quota of the given resource type in the project.</returns>
private int CalculateAllocatedForAll(ResourceType resourceType, Guid projectId)
{
var resourceTypeDefinition = ResourceTypeFactory.CreateResourceTypeObject(resourceType.DisplayName, _configuration);
var resources = _resourceModel.GetAllWhere((resource) =>
(from projectResource in resource.ProjectResources
where projectResource.ProjectId == projectId
select projectResource).Any() &&
resource.TypeId == resourceType.Id);
var allocated = resources.Sum(y => resourceTypeDefinition.GetResourceQuotaAvailable(y.Id.ToString(), _resourceModel.GetResourceTypeOptions(y.Id)).Result);
var allocated = resources.Sum(resource => ResourceTypeFactory
.Instance
.GetResourceType(resource)
.GetResourceQuotaAvailable(resource.Id.ToString(), _resourceModel.GetResourceTypeOptions(resource.Id))
.Result);
return (int)allocated;
}
......@@ -113,14 +115,18 @@ namespace Coscine.Api.Admin.Controllers
/// <returns>Used quota of the given resource type in the project.</returns>
private int CalculateUsedForAll(ResourceType resourceType, Guid projectId)
{
var resourceTypeDefinition = ResourceTypeFactory.CreateResourceTypeObject(resourceType.DisplayName, _configuration);
var resources = _resourceModel.GetAllWhere((resource) =>
(from projectResource in resource.ProjectResources
where projectResource.ProjectId == projectId
select projectResource).Any() &&
resource.TypeId == resourceType.Id);
var used = Math.Ceiling(resources.Sum(y => resourceTypeDefinition.GetResourceQuotaUsed(y.Id.ToString(), _resourceModel.GetResourceTypeOptions(y.Id)).Result / _oneGb));
var used = Math.Ceiling(resources.Sum(resource => ResourceTypeFactory
.Instance
.GetResourceType(resource)
.GetResourceQuotaUsed(resource.Id.ToString(), _resourceModel.GetResourceTypeOptions(resource.Id))
.Result / _oneGb));
return (int)used;
}
......