Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Database
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
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
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
libraries
Database
Merge requests
!146
Sprint/2021 19
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Sprint/2021 19
Sprint/2021-19
into
master
Overview
0
Commits
2
Pipelines
2
Changes
1
Merged
Petar Hristov
requested to merge
Sprint/2021-19
into
master
3 years ago
Overview
0
Commits
2
Pipelines
2
Changes
1
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
52cec7fa
2 commits,
3 years ago
1 file
+
17
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/Database/Models/ProjectModel.cs
+
17
−
4
Options
@@ -131,7 +131,7 @@ namespace Coscine.Database.Models
});
}
public
Project
StoreFromObject
(
ProjectObject
projectObject
,
User
user
,
I
Dictionary
<
string
,
int
>
defaultQuota
)
public
Project
StoreFromObject
(
ProjectObject
projectObject
,
User
user
,
I
Enumerable
<
ProjectQuota
>
default
Project
Quota
s
)
{
if
(!
projectObject
.
Disciplines
.
Any
()
||
!
projectObject
.
Organizations
.
Any
())
{
@@ -158,7 +158,7 @@ namespace Coscine.Database.Models
{
SetDisciplines
(
project
,
projectObject
.
Disciplines
);
SetOrganizations
(
project
,
projectObject
.
Organizations
);
SetQuotas
(
project
,
defaultQuota
);
SetQuotas
(
project
,
default
Project
Quota
s
);
}
catch
(
Exception
)
{
@@ -252,17 +252,30 @@ namespace Coscine.Database.Models
}
}
public
void
SetQuotas
(
Project
project
,
I
Dictionary
<
string
,
int
>
defaultQuotas
)
public
void
SetQuotas
(
Project
project
,
I
Enumerable
<
ProjectQuota
>
default
Project
Quotas
)
{
ProjectQuotaModel
projectQuotaModel
=
new
ProjectQuotaModel
();
ResourceTypeModel
resourceTypeModel
=
new
ResourceTypeModel
();
foreach
(
var
resourceType
in
resourceTypeModel
.
GetAll
())
{
int
quota
=
0
;
int
maxQuota
=
0
;
var
tDefaultQuotas
=
defaultProjectQuotas
.
Where
(
x
=>
x
.
ResourceTypeId
==
resourceType
.
Id
);
if
(
tDefaultQuotas
.
Any
())
{
quota
=
tDefaultQuotas
.
First
().
Quota
;
maxQuota
=
tDefaultQuotas
.
First
().
MaxQuota
;
}
projectQuotaModel
.
Insert
(
new
ProjectQuota
{
ProjectId
=
project
.
Id
,
ResourceTypeId
=
resourceType
.
Id
,
Quota
=
defaultQuotas
!=
null
&&
defaultQuotas
.
ContainsKey
(
resourceType
.
DisplayName
)
?
defaultQuotas
[
resourceType
.
DisplayName
]
:
0
Quota
=
quota
,
MaxQuota
=
maxQuota
});
}
}
Loading