Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
Doorcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Guardians of the Kretschmar Elock System
Doorcode
Commits
4ca0b794
Commit
4ca0b794
authored
Jul 06, 2020
by
Jacob Priddy
👌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make webserver depend on api
add door count to admin dasboard
parent
983daa39
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
3 deletions
+51
-3
docker-compose.yml.example
docker-compose.yml.example
+1
-0
src/backend/resources/views/admin/home.blade.php
src/backend/resources/views/admin/home.blade.php
+3
-3
src/backend/src/Gateways/Statistics/DatabaseStatisticsRepository.php
.../src/Gateways/Statistics/DatabaseStatisticsRepository.php
+8
-0
src/backend/src/Gateways/Statistics/InMemoryStatisticsRepository.php
.../src/Gateways/Statistics/InMemoryStatisticsRepository.php
+15
-0
src/backend/src/Gateways/Statistics/LocalStatisticsRepository.php
...end/src/Gateways/Statistics/LocalStatisticsRepository.php
+1
-0
src/backend/src/Gateways/Statistics/StatisticsRepository.php
src/backend/src/Gateways/Statistics/StatisticsRepository.php
+5
-0
src/backend/src/UseCases/Admin/Statistics/ResponseModel.php
src/backend/src/UseCases/Admin/Statistics/ResponseModel.php
+12
-0
src/backend/src/UseCases/Admin/Statistics/Statistics.php
src/backend/src/UseCases/Admin/Statistics/Statistics.php
+4
-0
src/backend/src/UseCases/Admin/Statistics/WebPresenter.php
src/backend/src/UseCases/Admin/Statistics/WebPresenter.php
+2
-0
No files found.
docker-compose.yml.example
View file @
4ca0b794
...
...
@@ -43,6 +43,7 @@ services:
- ./simple-saml-idp/metadata:/var/simplesamlphp-idp/metadata
depends_on:
- dbadmin
- api
logging:
options:
max-size: "10m"
...
...
src/backend/resources/views/admin/home.blade.php
View file @
4ca0b794
...
...
@@ -30,12 +30,12 @@
<
div
class
=
"card-body"
>
<
div
class
=
"row no-gutters align-items-center"
>
<
div
class
=
"col mr-2"
>
<
div
class
=
"text-xs font-weight-bold text-primary text-uppercase mb-1"
>
Earnings
(
Monthly
)
<
div
class
=
"text-xs font-weight-bold text-primary text-uppercase mb-1"
>
Doors
</
div
>
<
div
class
=
"h5 mb-0 font-weight-bold text-gray-800"
>
$
40
,
000
</
div
>
<
div
class
=
"h5 mb-0 font-weight-bold text-gray-800"
>
{{
$doorCount
}}
</
div
>
</
div
>
<
div
class
=
"col-auto"
>
<
i
class
=
"fas fa-
calendar
fa-2x text-gray-300"
></
i
>
<
i
class
=
"fas fa-
microchip
fa-2x text-gray-300"
></
i
>
</
div
>
</
div
>
</
div
>
...
...
src/backend/src/Gateways/Statistics/DatabaseStatisticsRepository.php
View file @
4ca0b794
...
...
@@ -167,4 +167,12 @@ QUERY;
),
$usage
->
usage_count
];
},
$doorUsages
);
}
/**
* @inheritDoc
*/
public
function
countDoors
():
int
{
return
\
App\Door
::
query
()
->
count
();
}
}
src/backend/src/Gateways/Statistics/InMemoryStatisticsRepository.php
View file @
4ca0b794
...
...
@@ -21,6 +21,8 @@ class InMemoryStatisticsRepository implements StatisticsRepository
*/
protected
array
$mostUsedDoors
=
[];
protected
int
$doorCount
;
public
function
addPercentage
(
DoorFailureRate
$failureRate
):
void
{
$this
->
failureRates
[]
=
$failureRate
;
...
...
@@ -58,4 +60,17 @@ class InMemoryStatisticsRepository implements StatisticsRepository
{
return
$this
->
mostUsedDoors
;
}
/**
* @inheritDoc
*/
public
function
countDoors
():
int
{
return
$this
->
doorCount
;
}
public
function
setDoorCount
(
int
$doorCount
):
void
{
$this
->
doorCount
=
$doorCount
;
}
}
src/backend/src/Gateways/Statistics/LocalStatisticsRepository.php
View file @
4ca0b794
...
...
@@ -15,5 +15,6 @@ class LocalStatisticsRepository extends InMemoryStatisticsRepository
$this
->
setActiveUsers
(
160
);
$this
->
addMostUsedDoor
(
1743
,
LocalDoorsRepository
::
getAmazonDoor
());
$this
->
addMostUsedDoor
(
635
,
LocalDoorsRepository
::
getTheBatCave
());
$this
->
setDoorCount
(
14
);
}
}
src/backend/src/Gateways/Statistics/StatisticsRepository.php
View file @
4ca0b794
...
...
@@ -16,6 +16,11 @@ interface StatisticsRepository
*/
public
function
countActiveUsers
(
Carbon
$start
,
Carbon
$end
):
int
;
/**
* @return int
*/
public
function
countDoors
():
int
;
/**
* @param \Carbon\Carbon $start
* @param \Carbon\Carbon $end
...
...
src/backend/src/UseCases/Admin/Statistics/ResponseModel.php
View file @
4ca0b794
...
...
@@ -16,6 +16,8 @@ class ResponseModel
protected
int
$activeUsers
=
0
;
protected
int
$doorCount
;
public
function
addFailureRate
(
DoorFailureRate
$failureRate
):
void
{
$this
->
failureRates
[]
=
$failureRate
;
...
...
@@ -31,6 +33,11 @@ class ResponseModel
$this
->
activeUsers
=
$active
;
}
public
function
setDoorCount
(
int
$count
):
void
{
$this
->
doorCount
=
$count
;
}
public
function
getActiveUsers
():
int
{
return
$this
->
activeUsers
;
...
...
@@ -45,4 +52,9 @@ class ResponseModel
{
return
$this
->
mostUsedDoors
;
}
public
function
getDoorCount
():
int
{
return
$this
->
doorCount
;
}
}
src/backend/src/UseCases/Admin/Statistics/Statistics.php
View file @
4ca0b794
...
...
@@ -57,10 +57,14 @@ class Statistics implements StatisticsUseCase
$usages
=
$this
->
statistics
->
mostUsedDoors
(
$start
,
$date
,
self
::
STATISTIC_LIMIT
);
$doors
=
$this
->
statistics
->
countDoors
();
$response
=
new
ResponseModel
();
$response
->
setActiveUsers
(
$this
->
statistics
->
countActiveUsers
(
$start
,
$date
));
$response
->
setDoorCount
(
$doors
);
foreach
(
$usages
as
$usage
)
{
$response
->
addMostUsedDoor
(
$usage
[
1
],
$usage
[
0
]);
}
...
...
src/backend/src/UseCases/Admin/Statistics/WebPresenter.php
View file @
4ca0b794
...
...
@@ -15,6 +15,8 @@ class WebPresenter extends BasePresenter implements Presenter
{
$this
->
viewModel
[
'activeUsers'
]
=
$responseModel
->
getActiveUsers
();
$this
->
viewModel
[
'doorCount'
]
=
$responseModel
->
getDoorCount
();
try
{
$this
->
viewModel
[
'failures'
][
'labels'
]
=
json_encode
(
array_map
(
static
function
(
DoorFailureRate
$rate
)
{
return
$rate
->
getDoor
()
->
getLocation
();
...
...
Write
Preview
Markdown
is supported
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