Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
oetzit
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
commul
oetzit
Commits
ce3926c4
Commit
ce3926c4
authored
2 years ago
by
Paolo.Brasolin
Browse files
Options
Downloads
Patches
Plain Diff
feat: #be plot device behaviour
parent
2d252f63
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/public/dashboard.js
+54
-0
54 additions, 0 deletions
backend/public/dashboard.js
backend/src/index.ts
+20
-1
20 additions, 1 deletion
backend/src/index.ts
backend/templates/dashboard.ejs
+5
-0
5 additions, 0 deletions
backend/templates/dashboard.ejs
with
79 additions
and
1 deletion
backend/public/dashboard.js
+
54
−
0
View file @
ce3926c4
...
@@ -104,3 +104,57 @@ new Chart(
...
@@ -104,3 +104,57 @@ new Chart(
document
.
getElementById
(
"
shotsByDurationChart
"
),
document
.
getElementById
(
"
shotsByDurationChart
"
),
shotsByDurationConfig
,
shotsByDurationConfig
,
);
);
//=[ Devices behaviour ]========================================================
const
devicesBehaviourData
=
JSON
.
parse
(
document
.
getElementById
(
"
devicesBehaviourData
"
).
textContent
,
)
.
filter
((
item
)
=>
item
.
device_id
)
.
map
((
item
)
=>
[
item
.
ended_count
,
item
.
interrupted_count
,
parseFloat
((
item
.
time_spent
/
100000
).
toFixed
(
2
)),
]);
console
.
log
(
devicesBehaviourData
);
const
devicesBehaviourConfig
=
{
type
:
"
bubble
"
,
data
:
{
datasets
:
[
{
data
:
devicesBehaviourData
,
backgroundColor
:
"
blue
"
,
},
],
},
options
:
{
// maintainAspectRatio: true,
// aspectRatio: 1,
scales
:
{
x
:
{
type
:
"
logarithmic
"
,
title
:
{
display
:
true
,
text
:
"
Finished games
"
,
},
},
y
:
{
type
:
"
logarithmic
"
,
title
:
{
display
:
true
,
text
:
"
Interrupted games
"
,
},
},
},
plugins
:
{
legend
:
{
display
:
false
},
},
},
};
new
Chart
(
document
.
getElementById
(
"
devicesBehaviourChart
"
),
devicesBehaviourConfig
,
);
This diff is collapsed.
Click to expand it.
backend/src/index.ts
+
20
−
1
View file @
ce3926c4
...
@@ -64,6 +64,25 @@ server.get("/", async (request, reply) => {
...
@@ -64,6 +64,25 @@ server.get("/", async (request, reply) => {
const
cluesCount
=
(
await
connection
.
table
(
"
clues
"
).
count
())[
0
].
count
;
const
cluesCount
=
(
await
connection
.
table
(
"
clues
"
).
count
())[
0
].
count
;
const
shotsCount
=
(
await
connection
.
table
(
"
shots
"
).
count
())[
0
].
count
;
const
shotsCount
=
(
await
connection
.
table
(
"
shots
"
).
count
())[
0
].
count
;
const
normalizedGames
=
connection
.
table
(
"
games
"
)
.
select
(
connection
.
raw
(
"
games.id, games.device_id, games.began_at_gmtm, games.ended_at_gmtm, max(shots.ended_at_gmtm) as last_shot_ended_at_gmtm
"
,
),
)
.
fullOuterJoin
(
"
shots
"
,
"
games.id
"
,
"
shots.game_id
"
)
.
groupBy
(
"
games.id
"
);
const
devicesBehaviour
=
await
connection
.
select
(
connection
.
raw
(
"
sum(coalesce (ended_at_gmtm, last_shot_ended_at_gmtm) - began_at_gmtm) as time_spent, count(case when ended_at_gmtm is not null then 1 end) as ended_count, count(case when ended_at_gmtm is null then 1 end) as interrupted_count, device_id
"
,
),
)
.
from
(
normalizedGames
.
as
(
"
g
"
))
.
groupBy
(
"
device_id
"
);
const
devicesByDate
=
await
connection
const
devicesByDate
=
await
connection
.
table
(
"
games
"
)
.
table
(
"
games
"
)
.
select
(
connection
.
raw
(
"
COUNT(DISTINCT device_id), DATE(began_at)
"
))
.
select
(
connection
.
raw
(
"
COUNT(DISTINCT device_id), DATE(began_at)
"
))
...
@@ -96,13 +115,13 @@ server.get("/", async (request, reply) => {
...
@@ -96,13 +115,13 @@ server.get("/", async (request, reply) => {
devicesByDate
,
devicesByDate
,
gamesByDate
,
gamesByDate
,
shotsByDuration
,
shotsByDuration
,
devicesBehaviour
,
});
});
});
});
// TODO: this is an horrible kludge
// TODO: this is an horrible kludge
import
fastifyStatic
from
"
fastify-static
"
;
import
fastifyStatic
from
"
fastify-static
"
;
import
path
from
"
path
"
;
import
path
from
"
path
"
;
import
{
connect
}
from
"
http2
"
;
server
.
register
(
fastifyStatic
,
{
server
.
register
(
fastifyStatic
,
{
root
:
path
.
join
(
__dirname
,
"
../public
"
),
root
:
path
.
join
(
__dirname
,
"
../public
"
),
prefix
:
"
/public/
"
,
prefix
:
"
/public/
"
,
...
...
This diff is collapsed.
Click to expand it.
backend/templates/dashboard.ejs
+
5
−
0
View file @
ce3926c4
...
@@ -88,6 +88,11 @@
...
@@ -88,6 +88,11 @@
<h1>
Shot count by duration [ms]
</h1>
<h1>
Shot count by duration [ms]
</h1>
<script
id=
"shotsByDurationData"
type=
"application/json"
>
<%-
JSON
.
stringify
(
shotsByDuration
)
%>
</script>
<script
id=
"shotsByDurationData"
type=
"application/json"
>
<%-
JSON
.
stringify
(
shotsByDuration
)
%>
</script>
<canvas
id=
"shotsByDurationChart"
></canvas>
<canvas
id=
"shotsByDurationChart"
></canvas>
<h1>
Total gametime per device [m]
</h1>
<script
id=
"devicesBehaviourData"
type=
"application/json"
>
<%-
JSON
.
stringify
(
devicesBehaviour
)
%>
</script>
<canvas
id=
"devicesBehaviourChart"
></canvas>
</main>
</main>
</div>
</div>
</div>
</div>
...
...
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