Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
apis
Admin
Commits
dfb37966
Commit
dfb37966
authored
May 30, 2022
by
L. Ellenbeck
Committed by
Petar Hristov
May 30, 2022
Browse files
Options
Downloads
Patches
Plain Diff
New: Updated to new resource types
parent
68d1cec0
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!36
New: Updated to new resource types
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Admin/Admin.csproj
+1
-1
1 addition, 1 deletion
src/Admin/Admin.csproj
src/Admin/Controllers/AdminController.cs
+15
-9
15 additions, 9 deletions
src/Admin/Controllers/AdminController.cs
with
16 additions
and
10 deletions
src/Admin/Admin.csproj
+
1
−
1
View file @
dfb37966
...
...
@@ -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.Resource
Loader
" Version="
2.
*-*" />
<PackageReference Include="Coscine.Resource
Types
" Version="*-*" />
</ItemGroup>
</Project>
This diff is collapsed.
Click to expand it.
src/Admin/Controllers/AdminController.cs
+
15
−
9
View file @
dfb37966
...
...
@@ -8,7 +8,7 @@ using Coscine.Database.DataModel;
using
Coscine.Database.Models
;
using
Coscine.Logging
;
using
Coscine.Metadata
;
using
Coscine.Resource
Loader
;
using
Coscine.Resource
Types
;
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
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment