Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from penevl/dev
Browse files Browse the repository at this point in the history
Merge dev branch
  • Loading branch information
penevl authored Apr 21, 2023
2 parents 06e94cc + 4b868aa commit 96cc787
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 88 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
68 changes: 63 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ require('dotenv').config()
const Gamedig = require('gamedig');
const mongoose = require('mongoose')
const fs = require('fs')
const ServerState = require('./stateModel')
const ServerState = require('./models/stateModel')
const nodeCron = require('node-cron')
const logger = require('skinwalker')
const express = require('express');
const AttendanceModel = require('./attendanceModel')
const AttendanceModel = require('./models/attendanceModel')
const app = express()

logger.init(process.env.LOG_LEVEL, {
Expand All @@ -16,7 +16,7 @@ logger.init(process.env.LOG_LEVEL, {
app.set('view engine', 'ejs');
logger.info('Set view engine to ejs', 'webserver')

app.use(express.static('./'))
app.use('/', express.static('./charts'))
app.use('/assets', express.static('./assets'))
logger.info('Served static files', 'webserver')

Expand Down Expand Up @@ -281,7 +281,7 @@ app.get('/echo', async (req, res) => {
})
temp.players = tempPlayers
temp.squadCount = tempPlayers.length
temp.attendance = ((temp.squadCount / echotSquad.length) * 100)
temp.attendance = ((temp.squadCount / echotSquad.length) * 100).toFixed(2)
serverLogs.unshift(temp)
})
logger.trace('serverLogs: ' + JSON.stringify(serverLogs), 'webserver/echo')
Expand All @@ -303,8 +303,37 @@ app.get('/echo', async (req, res) => {
})
logger.trace('chartData: ' + JSON.stringify(chartData), 'webserver/echo')

var individualAttendance = []

echotSquad.forEach(player => {
var temp = {
playerName: String,
attendance: Number
}
temp.playerName = player

logger.trace('Calculating attendance for player ' + player, 'webserver/echo')
var attended = 0

dbState.forEach(element => {
logger.trace('Checking attendance for ' + player + ' in operation ' + element.missionName, 'webserver/echo')
if(element.players.toString().replaceAll(/\s*\[.*?]/g, '').includes(player)){
logger.trace('Bumping attendance counter for player ' + player, 'webserver/echo')
attended++
}
})

logger.trace('Attended OPs for player ' + player + ' calculated to ' + attended, 'webserver/echo')
var att = ((attended / dbState.length) * 100).toFixed(2)
logger.trace('Attendedance for player ' + player + ' calculated to ' + att + '%', 'webserver/echo')
temp.attendance = att
individualAttendance.unshift(temp)
})
logger.trace('individualAttendance: ' + JSON.stringify(individualAttendance), 'webserver/echo')

res.render('echo', {
serverLogs: serverLogs,
individualAttendance: individualAttendance,
chartData: JSON.stringify(chartData)
})

Expand Down Expand Up @@ -343,7 +372,7 @@ app.get('/foxtrot', async (req, res) => {
})
temp.players = tempPlayers
temp.squadCount = tempPlayers.length
temp.attendance = ((temp.squadCount / foxtrotSquad.length) * 100)
temp.attendance = ((temp.squadCount / foxtrotSquad.length) * 100).toFixed(2)
serverLogs.unshift(temp)
})
logger.trace('serverLogs: ' + JSON.stringify(serverLogs), 'webserver/foxtrot')
Expand All @@ -365,8 +394,37 @@ app.get('/foxtrot', async (req, res) => {
})
logger.trace('chartData' + JSON.stringify(chartData), 'webserver/foxtrot')

var individualAttendance = []

foxtrotSquad.forEach(player => {
var temp = {
playerName: String,
attendance: Number
}
temp.playerName = player

logger.trace('Calculating attendance for player ' + player, 'webserver/foxtrot')
var attended = 0

dbState.forEach(element => {
logger.trace('Checking attendance for ' + player + ' in operation ' + element.missionName, 'webserver/foxtrot')
if(element.players.toString().replaceAll(/\s*\[.*?]/g, '').includes(player)){
logger.trace('Bumping attendance counter for player ' + player, 'webserver/foxtrot')
attended++
}
})

logger.trace('Attended OPs for player ' + player + ' calculated to ' + attended, 'webserver/foxtrot')
var att = ((attended / dbState.length) * 100).toFixed(2)
logger.trace('Attendedance for player ' + player + ' calculated to ' + att + '%', 'webserver/foxtrot')
temp.attendance = att
individualAttendance.unshift(temp)
})
logger.trace('individualAttendance: ' + JSON.stringify(individualAttendance), 'webserver/foxtrot')

res.render('foxtrot', {
serverLogs: serverLogs,
individualAttendance, individualAttendance,
chartData: JSON.stringify(chartData)
})

Expand Down
File renamed without changes.
File renamed without changes.
73 changes: 45 additions & 28 deletions views/echo.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,51 @@

<div class="page-content">
<div class="card-header"></div>
<div class="card-body">
<table class="table" id="table1">
<thead>
<tr>
<th>Mission name</th>
<th>Date</th>
<th>Player count</th>
<th>Squad count</th>
<th>Attendance</th>
<th>Players</th>
</tr>
</thead>
<tbody>

<% serverLogs.forEach(log => { %>
<tr>
<th><%= log.missionName %></th>
<td> <%= log.date %> </td>
<td> <%= log.playerCount %> </td>
<td> <%= log.squadCount %> </td>
<td> <%= log.attendance %> %</td>
<td> <%= log.players %> </td>
</tr>
<% }) %>

</tbody>
</table>
<div class="card-body">
<table class="table" id="table1">
<thead>
<tr>
<th>Mission name</th>
<th>Date</th>
<th>Player count</th>
<th>Squad count</th>
<th>Attendance</th>
<th>Players</th>
</tr>
</thead>
<tbody>
<% serverLogs.forEach(log => { %>
<tr>
<th><%= log.missionName %></th>
<td> <%= log.date %> </td>
<td> <%= log.playerCount %> </td>
<td> <%= log.squadCount %> </td>
<td> <%= log.attendance %> %</td>
<td> <%= log.players %> </td>
</tr>
<% }) %>
</tbody>
</table>

<div class="page-heading">
<h3>Individual Attendance</h3>
</div>

<table class="table" id="table1">
<thead>
<tr>
<th>Player name</th>
<th>Attendance(%)</th>
</thead>
<tbody>
<% individualAttendance.forEach(log => { %>
<tr>
<th><%= log.playerName %></th>
<td> <%= log.attendance %> </td>
</tr>
<% }) %>
</tbody>
</table>

<div id="chart"></div>

Expand Down
77 changes: 48 additions & 29 deletions views/foxtrot.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,55 @@

<div class="page-content">
<div class="card-header"></div>
<div class="card-body">
<table class="table" id="table1">
<thead>
<tr>
<th>Mission name</th>
<th>Date</th>
<th>Player count</th>
<th>Squad count</th>
<th>Attendance</th>
<th>Players</th>
</tr>
</thead>
<tbody>

<% serverLogs.forEach(log => { %>
<tr>
<th><%= log.missionName %></th>
<td> <%= log.date %> </td>
<td> <%= log.playerCount %> </td>
<td> <%= log.squadCount %> </td>
<td> <%= log.attendance %> %</td>
<td> <%= log.players %> </td>
</tr>
<% }) %>

</tbody>
</table>
<div class="card-body">
<table class="table" id="table1">
<thead>
<tr>
<th>Mission name</th>
<th>Date</th>
<th>Player count</th>
<th>Squad count</th>
<th>Attendance</th>
<th>Players</th>
</tr>
</thead>
<tbody>
<% serverLogs.forEach(log => { %>
<tr>
<th><%= log.missionName %></th>
<td> <%= log.date %> </td>
<td> <%= log.playerCount %> </td>
<td> <%= log.squadCount %> </td>
<td> <%= log.attendance %> %</td>
<td> <%= log.players %> </td>
</tr>
<% }) %>
</tbody>
</table>

<div id="chart"></div>
<div class="page-heading">
<h3>Individual Attendance</h3>
</div>

<table class="table" id="table1">
<thead>
<tr>
<th>Player name</th>
<th>Attendance(%)</th>
</tr>
</thead>
<tbody>
<% individualAttendance.forEach(log => { %>
<tr>
<th><%= log.playerName %></th>
<td> <%= log.attendance %> </td>
</tr>
<% }) %>
</tbody>
</table>

<div id="chart"></div>

</div>
</div>
Expand Down
48 changes: 22 additions & 26 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,29 @@

<div class="page-content">
<div class="card-header"></div>
<div class="card-body">
<table class="table" id="table1">
<thead>
<tr>
<th>Mission name</th>
<th>Date</th>
<th>Player count</th>
<th>Players</th>
</tr>
</thead>
<tbody>

<% serverLogs.forEach(log => { %>
<tr>
<th><%= log.missionName %></th>
<td> <%= log.date %> </td>
<td> <%= log.playerCount %> </td>
<td> <%= log.players %> </td>
</tr>
<% }) %>

</tbody>
</table>
<div class="card-body">
<table class="table" id="table1">
<thead>
<tr>
<th>Mission name</th>
<th>Date</th>
<th>Player count</th>
<th>Players</th>
</tr>
</thead>
<tbody>
<% serverLogs.forEach(log => { %>
<tr>
<th><%= log.missionName %></th>
<td> <%= log.date %> </td>
<td> <%= log.playerCount %> </td>
<td> <%= log.players %> </td>
</tr>
<% }) %>
</tbody>
</table>

<div id="chart"></div>
<div id="chart"></div>

</div>
</div>
Expand Down

0 comments on commit 96cc787

Please sign in to comment.