-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding the page that will show the data for the stats (and the …
…stats api endpoint)
- Loading branch information
Showing
4 changed files
with
191 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
@page | ||
@model CFLookup.Pages.MinecraftModStatsOverTimeModel | ||
@{ | ||
ViewData["Title"] = "Minecraft mod stats over time"; | ||
} | ||
@section Head { | ||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | ||
<script> | ||
google.charts.load('current', { packages: ['linechart'] }); | ||
google.charts.setOnLoadCallback(drawMinecraftChart); | ||
function drawMinecraftChart() { | ||
var data = new google.visualization.DataTable(); | ||
data.addColumn('datetime', 'Time'); | ||
data.addColumn('string', 'Game version'); | ||
data.addColumn('number', 'Forge'); | ||
data.addColumn('number', 'Fabric'); | ||
data.addColumn('number', 'Quilt'); | ||
data.addColumn('number', 'NeoForge'); | ||
const jsonData = @Html.Raw(Json.Serialize(Model.Stats)); | ||
for(var stat in jsonData) | ||
{ | ||
let rowData = jsonData[stat]; | ||
for(var gameVersion in rowData) | ||
{ | ||
let row = []; | ||
row.push(new Date(stat)); | ||
row.push(gameVersion); | ||
row.push(rowData[gameVersion]["Forge"]); | ||
row.push(rowData[gameVersion]["Fabric"]); | ||
row.push(rowData[gameVersion]["Quilt"]); | ||
row.push(rowData[gameVersion]["NeoForge"]); | ||
console.log(row); | ||
data.addRow(row); | ||
} | ||
} | ||
var options = { | ||
title: 'Number of Minecraft mods per game version, per mod loader', | ||
height: '700', | ||
width: '100%', | ||
isStacked: true, | ||
legend: { | ||
position: 'bottom', | ||
textStyle: { color: '#6c757d' } | ||
}, | ||
vAxis: { | ||
title: 'Minecraft game version', | ||
titleTextStyle: { color: '#6c757d' }, | ||
textStyle: { color: '#6c757d' }, | ||
gridlines: { color: '#787878' } | ||
}, | ||
backgroundColor: { fill: 'transparent' }, | ||
titleTextStyle: { | ||
color: '#fff' | ||
}, | ||
hAxis: { | ||
textStyle: { color: '#6c757d' }, | ||
titleTextStyle: { color: '#6c757d' }, | ||
gridlines: { color: '#787878' }, | ||
title: 'Time' | ||
} | ||
}; | ||
var chart = new google.visualization.LineChart(document.getElementById('minecraft-version-modloader')); | ||
chart.draw(data, options); | ||
} | ||
</script> | ||
} | ||
|
||
<div id="minecraft-version-modloader"></div> | ||
|
||
<table class="table table-dark table-striped table-condensed"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Timestamp</th> | ||
<th scope="col" class="text-end">VersionInfo</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach(var stat in Model.Stats) | ||
{ | ||
<tr> | ||
<td scope="row">@stat.Key</td> | ||
<td> | ||
<table class="table table-dark table-striped table-condensed"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Game version</th> | ||
<th scope="col">Forge</th> | ||
<th scope="col">Fabric</th> | ||
<th scope="col">Quilt</th> | ||
<th scope="col">NeoForge</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach(var gameVersion in stat.Value) | ||
{ | ||
<tr> | ||
<td scope="row">@gameVersion.Key</td> | ||
<td>@gameVersion.Value["Forge"].ToString("n0")</td> | ||
<td>@gameVersion.Value["Fabric"].ToString("n0")</td> | ||
<td>@gameVersion.Value["Quilt"].ToString("n0")</td> | ||
<td>@gameVersion.Value["NeoForge"].ToString("n0")</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using System.Data; | ||
using System.Text.Json; | ||
|
||
namespace CFLookup.Pages | ||
{ | ||
public class MinecraftModStatsOverTimeModel : PageModel | ||
{ | ||
private readonly MSSQLDB _db; | ||
|
||
public Dictionary<DateTimeOffset, Dictionary<string, Dictionary<string, long>>> Stats { get; set; } = new Dictionary<DateTimeOffset, Dictionary<string, Dictionary<string, long>>>(); | ||
|
||
public MinecraftModStatsOverTimeModel(MSSQLDB db) | ||
{ | ||
_db = db; | ||
} | ||
|
||
public async Task OnGetAsync() | ||
{ | ||
Stats = await SharedMethods.GetMinecraftStatsOverTime(_db); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters