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
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
libraries
Database
Commits
bfd6aa32
Commit
bfd6aa32
authored
3 years ago
by
L. Ellenbeck
Committed by
Petar Hristov
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update: Inclusion of max quota on project creation (rpdm/issues#28)
parent
9e15c001
No related branches found
No related tags found
2 merge requests
!146
Sprint/2021 19
,
!145
Issues/0028 max quota fix
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Database/Models/ProjectModel.cs
+17
-4
17 additions, 4 deletions
src/Database/Models/ProjectModel.cs
with
17 additions
and
4 deletions
src/Database/Models/ProjectModel.cs
+
17
−
4
View file @
bfd6aa32
...
...
@@ -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
});
}
}
...
...
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