Skip to content

Commit

Permalink
Forgot that Status and Value were implemented as getters, so no paren…
Browse files Browse the repository at this point in the history
…theses needed.'
  • Loading branch information
LswaN58 committed Jun 5, 2024
1 parent 80e5bec commit 5ac70f9
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions site/assets/scripts/game_usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ document.addEventListener('DOMContentLoaded', () => {

getGameUsage(gameId)
.then(function (response) {
if (response.Status() == "SUCCESS") {
if (response.Status == "SUCCESS") {
// update the months and year
var currentJSMonth = currentMonth - 1;
var currentMonthName = new Date(currentYear, currentJSMonth).toLocaleString('default', { month: 'long' });

gameUsage = new GameUsage(response.Value().gameId, response.Value().sessions);
gameUsage = new GameUsage(response.Value.gameId, response.Value.sessions);
currentSession = gameUsage.sessions.find(e => e.month === currentMonth && e.year === currentYear);
// update the game usage information
var monthlySessions = currentSession.total_sessions < 1000 ? currentSession.total_sessions : (currentSession.total_sessions / 1000).toFixed(0) + 'K';
Expand Down Expand Up @@ -188,7 +188,7 @@ function updateHtml(gameId, currentYear, currentMonth) {
// get game files for that month
getGameFiles(gameId, currentYear, currentMonth)
.then(function (response) {
if (response.Status() == "SUCCESS") {
if (response.Status == "SUCCESS") {

// update the months and year
var currentJSMonth = currentMonth - 1;
Expand All @@ -200,37 +200,37 @@ function updateHtml(gameId, currentYear, currentMonth) {
statsHeader.innerHTML = currentMonthName + ' ' + currentYear;

// update next / previous to be enabled or disabled depending on what other data exists
nextMonth.disabled = (response.Value().last_year < currentYear || (response.Value().last_year === currentYear && response.Value().last_month <= currentMonth)) ? true : false;
prevMonth.disabled = (response.Value().first_year > currentYear || (response.Value().first_year === currentYear && response.Value().first_month >= currentMonth)) ? true : false;
nextMonth.disabled = (response.Value.last_year < currentYear || (response.Value.last_year === currentYear && response.Value.last_month <= currentMonth)) ? true : false;
prevMonth.disabled = (response.Value.first_year > currentYear || (response.Value.first_year === currentYear && response.Value.first_month >= currentMonth)) ? true : false;

// Update the general template links, showing/hiding as appropriate

if (response.Value().events_template) {
eventsData.href = response.Value().events_template;
if (response.Value.events_template) {
eventsData.href = response.Value.events_template;
eventsData.classList.remove('d-none');
}
else {
eventsData.classList.add('d-none');
}

if (response.Value().players_template) {
playersData.href = response.Value().players_template;
if (response.Value.players_template) {
playersData.href = response.Value.players_template;
playersData.classList.remove('d-none');
}
else {
playersData.classList.add('d-none');
}

if (response.Value().population_template) {
populationData.href = response.Value().population_template;
if (response.Value.population_template) {
populationData.href = response.Value.population_template;
populationData.classList.remove('d-none');
}
else {
populationData.classList.add('d-none');
}

if (response.Value().sessions_template) {
sessionsData.href = response.Value().sessions_template;
if (response.Value.sessions_template) {
sessionsData.href = response.Value.sessions_template;
sessionsData.classList.remove('d-none');
}
else {
Expand All @@ -241,11 +241,11 @@ function updateHtml(gameId, currentYear, currentMonth) {
document.getElementById('pipeline-month').innerText = 'Month of ' + currentMonthName;

// Enable/disable buttons in pipeline
rawBtn.disabled = response.Value().raw_file ? false : true;
detectorBtn.disabled = response.Value().detectors_link ? false : true;
eventBtn.disabled = response.Value().events_file ? false : true;
extractorBtn.disabled = response.Value().features_link ? false : true;
featureBtn.disabled = response.Value().population_file || response.Value().players_file || response.Value().sessions_file ? false : true;
rawBtn.disabled = response.Value.raw_file ? false : true;
detectorBtn.disabled = response.Value.detectors_link ? false : true;
eventBtn.disabled = response.Value.events_file ? false : true;
extractorBtn.disabled = response.Value.features_link ? false : true;
featureBtn.disabled = response.Value.population_file || response.Value.players_file || response.Value.sessions_file ? false : true;

// Determine the selector for the earliest data pipeline button that has data
// We'll make that button active
Expand Down Expand Up @@ -311,49 +311,49 @@ function updateHtml(gameId, currentYear, currentMonth) {
// Update the links in each of the target blocks
let linksRaw = '';

if (response.Value().raw_file) {
linksRaw = '<a class="btn btn-primary mb-2" href="' + response.Value().raw_file + '">Raw Data<i class="bi bi-arrow-down"></i></a>';
if (response.Value.raw_file) {
linksRaw = '<a class="btn btn-primary mb-2" href="' + response.Value.raw_file + '">Raw Data<i class="bi bi-arrow-down"></i></a>';
}

document.getElementById('pipeline-target-links-raw').innerHTML = linksRaw;

let linksDetectors = '';

if (response.Value().detectors_link) {
linksDetectors = '<a class="btn btn-primary mb-2" href="' + response.Value().detectors_link + '">Detectors<i class="bi bi-arrow-down"></i></a>';
if (response.Value.detectors_link) {
linksDetectors = '<a class="btn btn-primary mb-2" href="' + response.Value.detectors_link + '">Detectors<i class="bi bi-arrow-down"></i></a>';
}


document.getElementById('pipeline-target-links-detector').innerHTML = linksDetectors;

let linksEvents = '';

if (response.Value().events_file) {
linksEvents = '<a class="btn btn-primary mb-2" href="' + response.Value().events_file + '">Calculated Events<i class="bi bi-arrow-down"></i></a>';
if (response.Value.events_file) {
linksEvents = '<a class="btn btn-primary mb-2" href="' + response.Value.events_file + '">Calculated Events<i class="bi bi-arrow-down"></i></a>';
}

document.getElementById('pipeline-target-links-event').innerHTML = linksEvents;

let linksExtractors = '';

if (response.Value().features_link) {
linksExtractors = '<a class="btn btn-primary mb-2" href="' + response.Value().features_link + '">Extractors<i class="bi bi-arrow-down"></i></a>';
if (response.Value.features_link) {
linksExtractors = '<a class="btn btn-primary mb-2" href="' + response.Value.features_link + '">Extractors<i class="bi bi-arrow-down"></i></a>';
}

document.getElementById('pipeline-target-links-extractor').innerHTML = linksExtractors;

let linksFeature = '';

if (response.Value().population_file) {
linksFeature += '<a class="btn btn-primary mb-2" href="' + response.Value().population_file + '">Population Features<i class="bi bi-arrow-down"></i></a>';
if (response.Value.population_file) {
linksFeature += '<a class="btn btn-primary mb-2" href="' + response.Value.population_file + '">Population Features<i class="bi bi-arrow-down"></i></a>';
}

if (response.Value().players_file) {
linksFeature += '<a class="btn btn-primary mb-2" href="' + response.Value().players_file + '">Player Features<i class="bi bi-arrow-down"></i></a>';
if (response.Value.players_file) {
linksFeature += '<a class="btn btn-primary mb-2" href="' + response.Value.players_file + '">Player Features<i class="bi bi-arrow-down"></i></a>';
}

if (response.Value().sessions_file) {
linksFeature += '<a class="btn btn-primary mb-2" href="' + response.Value().sessions_file + '">Session Features<i class="bi bi-arrow-down"></i></a>';
if (response.Value.sessions_file) {
linksFeature += '<a class="btn btn-primary mb-2" href="' + response.Value.sessions_file + '">Session Features<i class="bi bi-arrow-down"></i></a>';
}

document.getElementById('pipeline-target-links-feature').innerHTML = linksFeature;
Expand Down

0 comments on commit 5ac70f9

Please sign in to comment.