Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Assignment2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bad
Assignment2
Compare revisions
eaf8a5ef795035cccf67b20de83a26931099c2c4 to 69b1b69462fb67a0b47e41a6a2c64e19660a8207
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
bad1/assignment2
Select target project
No results found
69b1b69462fb67a0b47e41a6a2c64e19660a8207
Select Git revision
Swap
Target
bad1/assignment2
Select target project
bad1/assignment2
1 result
eaf8a5ef795035cccf67b20de83a26931099c2c4
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Level i logentry
· 93dd92a9
Nikoline Vistoft Bartholin
authored
2 weeks ago
93dd92a9
Merge branch 'main' of
https://gitlab.au.dk/bad1/assignment2
· 69b1b694
Nikoline Vistoft Bartholin
authored
2 weeks ago
69b1b694
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Controllers/LogController.cs
+2
-2
2 additions, 2 deletions
Controllers/LogController.cs
Interfaces/ILogService.cs
+1
-1
1 addition, 1 deletion
Interfaces/ILogService.cs
Models/LogInfo.cs
+1
-1
1 addition, 1 deletion
Models/LogInfo.cs
Services/LogsService.cs
+6
-1
6 additions, 1 deletion
Services/LogsService.cs
with
10 additions
and
5 deletions
Controllers/LogController.cs
View file @
69b1b694
...
@@ -18,9 +18,9 @@ namespace assignment2.Controllers
...
@@ -18,9 +18,9 @@ namespace assignment2.Controllers
//[Authorize(Roles = "Admin")]
//[Authorize(Roles = "Admin")]
[
HttpGet
]
[
HttpGet
]
public
async
Task
<
IActionResult
>
GetAsync
(
string
?
user
,
string
?
operation
,
DateTime
?
startDate
,
DateTime
?
endTime
)
public
async
Task
<
IActionResult
>
GetAsync
(
string
?
user
,
string
?
operation
,
DateTime
?
startDate
,
DateTime
?
endTime
,
string
?
level
)
{
{
var
logs
=
await
_logsService
.
GetAsync
(
user
,
operation
,
startDate
,
endTime
);
var
logs
=
await
_logsService
.
GetAsync
(
user
,
operation
,
startDate
,
endTime
,
level
);
return
Ok
(
logs
);
return
Ok
(
logs
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Interfaces/ILogService.cs
View file @
69b1b694
...
@@ -8,6 +8,6 @@ namespace assignment2.Interfaces
...
@@ -8,6 +8,6 @@ namespace assignment2.Interfaces
{
{
public
interface
ILogService
public
interface
ILogService
{
{
Task
<
IEnumerable
<
LogEntry
>>
GetAsync
(
string
?
user
,
string
?
operation
,
DateTime
?
startDate
,
DateTime
?
endTime
);
Task
<
IEnumerable
<
LogEntry
>>
GetAsync
(
string
?
user
,
string
?
operation
,
DateTime
?
startDate
,
DateTime
?
endTime
,
string
?
level
);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Models/LogInfo.cs
View file @
69b1b694
...
@@ -18,5 +18,5 @@ namespace assignment2.Models
...
@@ -18,5 +18,5 @@ namespace assignment2.Models
[
BsonElement
(
"Timestamp"
)]
[
BsonElement
(
"Timestamp"
)]
[
BsonDateTimeOptions
(
Kind
=
DateTimeKind
.
Utc
)]
[
BsonDateTimeOptions
(
Kind
=
DateTimeKind
.
Utc
)]
public
DateTime
Timestamp
{
get
;
set
;
}
=
DateTime
.
UtcNow
;
public
DateTime
Timestamp
{
get
;
set
;
}
=
DateTime
.
UtcNow
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Services/LogsService.cs
View file @
69b1b694
...
@@ -37,7 +37,7 @@ namespace assignment2.Services
...
@@ -37,7 +37,7 @@ namespace assignment2.Services
}
}
public
async
Task
<
IEnumerable
<
LogEntry
>>
GetAsync
(
string
?
user
,
string
?
operation
,
DateTime
?
startDate
,
DateTime
?
endTime
)
public
async
Task
<
IEnumerable
<
LogEntry
>>
GetAsync
(
string
?
user
,
string
?
operation
,
DateTime
?
startDate
,
DateTime
?
endTime
,
string
?
level
)
{
{
var
builder
=
Builders
<
LogEntry
>.
Filter
;
var
builder
=
Builders
<
LogEntry
>.
Filter
;
...
@@ -60,6 +60,11 @@ namespace assignment2.Services
...
@@ -60,6 +60,11 @@ namespace assignment2.Services
filters
.
Add
(
builder
.
And
(
builder
.
Gte
(
u
=>
u
.
Properties
.
LogInfo
.
Timestamp
,
startDate
),
builder
.
Lte
(
u
=>
u
.
Properties
.
LogInfo
.
Timestamp
,
endTime
)));
filters
.
Add
(
builder
.
And
(
builder
.
Gte
(
u
=>
u
.
Properties
.
LogInfo
.
Timestamp
,
startDate
),
builder
.
Lte
(
u
=>
u
.
Properties
.
LogInfo
.
Timestamp
,
endTime
)));
Console
.
WriteLine
(
$"Filtering by date range:
{
startDate
}
to
{
endTime
}
"
);
Console
.
WriteLine
(
$"Filtering by date range:
{
startDate
}
to
{
endTime
}
"
);
}
}
if
(!
string
.
IsNullOrEmpty
(
level
))
{
filters
.
Add
(
builder
.
Eq
(
u
=>
u
.
Level
,
level
));
Console
.
WriteLine
(
$"Filtering by level:
{
level
}
"
);
}
var
filter
=
filters
.
Count
>
0
?
builder
.
And
(
filters
)
:
builder
.
Empty
;
var
filter
=
filters
.
Count
>
0
?
builder
.
And
(
filters
)
:
builder
.
Empty
;
...
...
This diff is collapsed.
Click to expand it.