Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Coscine
backend
libraries
Database
Commits
7b20e092
Commit
7b20e092
authored
Nov 04, 2020
by
Marcel Nellesen
Browse files
Extracted functionality (coscine/issues#1051)
parent
8616d313
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Database.T4/Properties/AssemblyInfo.cs
View file @
7b20e092
...
...
@@ -11,6 +11,6 @@ using System.Reflection;
[
assembly
:
AssemblyProduct
(
"Database.T4"
)]
[
assembly
:
AssemblyVersion
(
"1.25.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.25.0"
)]
[
assembly
:
AssemblyInformationalVersion
(
"1.25.0-topic-1051-basic000
3
"
)]
[
assembly
:
AssemblyInformationalVersion
(
"1.25.0-topic-1051-basic000
5
"
)]
[
assembly
:
AssemblyCopyright
(
"2020 IT Center, RWTH Aachen University"
)]
src/Database.Tests/Properties/AssemblyInfo.cs
View file @
7b20e092
...
...
@@ -11,6 +11,6 @@ using System.Reflection;
[
assembly
:
AssemblyProduct
(
"Database.Tests"
)]
[
assembly
:
AssemblyVersion
(
"1.25.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.25.0"
)]
[
assembly
:
AssemblyInformationalVersion
(
"1.25.0-topic-1051-basic000
3
"
)]
[
assembly
:
AssemblyInformationalVersion
(
"1.25.0-topic-1051-basic000
5
"
)]
[
assembly
:
AssemblyCopyright
(
"2020 IT Center, RWTH Aachen University"
)]
src/Database/Database.csproj
View file @
7b20e092
...
...
@@ -93,6 +93,8 @@
<Compile
Include=
"ReturnObjects\KpiObject.cs"
/>
<Compile
Include=
"ReturnObjects\LanguageObject.cs"
/>
<Compile
Include=
"ReturnObjects\LicenseObject.cs"
/>
<Compile
Include=
"ReturnObjects\OrganizationResourceListObject.cs"
/>
<Compile
Include=
"ReturnObjects\OrganizationCountObject.cs"
/>
<Compile
Include=
"ReturnObjects\OrganizationObject.cs"
/>
<Compile
Include=
"ReturnObjects\ProjectObject.cs"
/>
<Compile
Include=
"ReturnObjects\ProjectQuotaObject.cs"
/>
...
...
src/Database/Models/ProjectModel.cs
View file @
7b20e092
...
...
@@ -170,6 +170,20 @@ namespace Coscine.Database.Models
return
project
;
}
public
List
<
OrganizationCountObject
>
GetProjectCountByOrganization
()
{
return
DatabaseConnection
.
ConnectToDatabase
((
db
)
=>
{
return
(
from
p
in
db
.
Projects
join
pi
in
db
.
ProjectInstitutes
on
p
.
Id
equals
pi
.
ProjectId
into
joinedPi
from
jpi
in
joinedPi
.
DefaultIfEmpty
()
where
p
.
Deleted
==
false
group
jpi
by
jpi
.
OrganizationUrl
into
g
select
new
OrganizationCountObject
(
g
.
Key
,
g
.
Count
())).
ToList
();
});
}
private
String
GenerateSlug
(
ProjectObject
projectObject
)
{
// create slug for project
...
...
src/Database/Models/ResourceModel.cs
View file @
7b20e092
...
...
@@ -72,6 +72,38 @@ namespace Coscine.Database.Models
return
Delete
(
resource
);
}
public
List
<
OrganizationCountObject
>
GetRDSBucketCountByOrganization
()
{
var
resourceListByOrganization
=
GetRDSResourceListByOrganization
();
var
list
=
new
List
<
OrganizationCountObject
>();
foreach
(
OrganizationResourceListObject
rlo
in
resourceListByOrganization
)
{
list
.
Add
(
new
OrganizationCountObject
(
rlo
.
Url
,
rlo
.
Resources
.
Count
));
}
return
list
;
}
public
List
<
OrganizationResourceListObject
>
GetRDSResourceListByOrganization
()
{
return
DatabaseConnection
.
ConnectToDatabase
((
db
)
=>
{
return
(
from
r
in
db
.
Resources
join
pr
in
db
.
ProjectResources
on
r
.
Id
equals
pr
.
ResourceId
into
joinedPr
from
jpr
in
joinedPr
.
DefaultIfEmpty
()
join
p
in
db
.
Projects
on
jpr
.
ProjectId
equals
p
.
Id
into
joinedP
from
jp
in
joinedP
.
DefaultIfEmpty
()
join
pi
in
db
.
ProjectInstitutes
on
jp
.
Id
equals
pi
.
ProjectId
into
joinedPi
from
jpi
in
joinedPi
.
DefaultIfEmpty
()
join
rt
in
db
.
ResourceTypes
on
r
.
TypeId
equals
rt
.
Id
into
joinedRt
from
jrt
in
joinedRt
.
DefaultIfEmpty
()
where
jp
.
Deleted
==
false
&&
jrt
.
DisplayName
==
"rds"
group
r
by
jpi
.
OrganizationUrl
into
g
select
new
OrganizationResourceListObject
(
g
.
Key
,
g
.
ToList
())).
ToList
();
});
}
private
void
SetResourceTypeObject
(
Resource
resource
,
JObject
resourceTypeOption
)
{
if
(
resource
.
Type
.
DisplayName
==
"rds"
)
...
...
src/Database/Models/UserModel.cs
View file @
7b20e092
using
Coscine.Database.DataModel
;
using
Coscine.Database.ReturnObjects
;
using
Coscine.Database.Util
;
using
LinqToDB
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -89,6 +90,16 @@ namespace Coscine.Database.Models
return
Update
(
user
);
}
public
List
<
Guid
>
GetActiveUserIds
()
{
return
DatabaseConnection
.
ConnectToDatabase
((
db
)
=>
{
return
(
from
u
in
db
.
Users
join
tos
in
db
.
TOSAccepteds
on
u
.
Id
equals
tos
.
UserId
select
u
.
Id
).
Distinct
().
ToList
();
});
}
private
void
SetDisciplines
(
User
user
,
IEnumerable
<
DisciplineObject
>
disciplines
)
{
UserDisciplineModel
userDisciplineModel
=
new
UserDisciplineModel
();
...
...
src/Database/Properties/AssemblyInfo.cs
View file @
7b20e092
...
...
@@ -11,6 +11,6 @@ using System.Reflection;
[
assembly
:
AssemblyProduct
(
"Database"
)]
[
assembly
:
AssemblyVersion
(
"1.25.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.25.0"
)]
[
assembly
:
AssemblyInformationalVersion
(
"1.25.0-topic-1051-basic000
3
"
)]
[
assembly
:
AssemblyInformationalVersion
(
"1.25.0-topic-1051-basic000
5
"
)]
[
assembly
:
AssemblyCopyright
(
"2020 IT Center, RWTH Aachen University"
)]
src/Database/ReturnObjects/OrganizationCountObject.cs
0 → 100644
View file @
7b20e092
using
System
;
namespace
Coscine.Database.ReturnObjects
{
[
Serializable
]
public
class
OrganizationCountObject
:
IReturnObject
{
public
string
Url
{
get
;
set
;
}
public
int
Count
{
get
;
set
;
}
public
OrganizationCountObject
(
string
url
,
int
count
)
{
Url
=
url
;
Count
=
count
;
}
}
}
src/Database/ReturnObjects/OrganizationResourceListObject.cs
0 → 100644
View file @
7b20e092
using
Coscine.Database.DataModel
;
using
System
;
using
System.Collections.Generic
;
namespace
Coscine.Database.ReturnObjects
{
[
Serializable
]
public
class
OrganizationResourceListObject
:
IReturnObject
{
public
string
Url
{
get
;
set
;
}
public
List
<
Resource
>
Resources
{
get
;
set
;
}
public
OrganizationResourceListObject
(
string
url
,
List
<
Resource
>
resources
)
{
Url
=
url
;
Resources
=
resources
;
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment