Skip to content
Draft

2.0 #119

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
54f5480
add Stats Page
TheSwerik Mar 2, 2023
4ffd9f9
add Navbar
TheSwerik Mar 2, 2023
ba3d327
fix Dispose
TheSwerik Mar 2, 2023
9f047cd
add Planning
TheSwerik Mar 2, 2023
677d811
add JavaScript MicroProject
TheSwerik Mar 2, 2023
6b792c8
add rough sketch
TheSwerik Mar 2, 2023
46d07bd
fix NavBar width
TheSwerik Mar 2, 2023
263bd0b
move ScrollToBottom to typescript
TheSwerik Mar 2, 2023
7277bc8
move theme
TheSwerik Mar 2, 2023
895c5dc
cleanup
TheSwerik Mar 2, 2023
8edae9b
cleanup
TheSwerik Mar 2, 2023
54840fa
add UpdateService
TheSwerik Mar 8, 2023
cf30d9f
cleanup
TheSwerik Mar 8, 2023
415c868
fix update
TheSwerik Mar 8, 2023
90feb83
remove unused method
TheSwerik Mar 8, 2023
ce1c21a
cleanup
TheSwerik Mar 8, 2023
3af8641
fix imprint centering
TheSwerik Mar 9, 2023
bac7567
idk what I did
TheSwerik Mar 10, 2023
cf2a14a
ew
TheSwerik Mar 10, 2023
e570eac
Merge branch 'main' into 2.0
TheSwerik Aug 28, 2023
f833b7b
add gzip
TheSwerik Aug 28, 2023
30b2105
refactor to proper Clean Architecture
TheSwerik Aug 29, 2023
02283b2
fix Imports
TheSwerik Sep 18, 2023
8810ee8
fix stuff
TheSwerik Sep 18, 2023
b552f4c
fix Application
TheSwerik Sep 18, 2023
3815772
cleanup
TheSwerik Sep 18, 2023
825be58
change Analytics Service to MiddleWare
TheSwerik Sep 18, 2023
da9bb2e
cleanup
TheSwerik Sep 18, 2023
c3a629e
cleanup
TheSwerik Sep 18, 2023
3ebdbea
fix analytics service
TheSwerik Sep 18, 2023
e0feb54
sad
TheSwerik Sep 18, 2023
bf323e3
cleanup
TheSwerik Sep 18, 2023
5fa86ec
fix analytics
TheSwerik Sep 18, 2023
a16a8dc
cleanup
TheSwerik Sep 18, 2023
8b7ac7a
cleanup
TheSwerik Sep 18, 2023
53ca90a
cleanup
TheSwerik Sep 18, 2023
d560a05
cleanup
TheSwerik Sep 18, 2023
8d12647
remove useless service
TheSwerik Sep 18, 2023
463e024
remove useless service
TheSwerik Sep 18, 2023
1915fa3
cleanup
TheSwerik Sep 18, 2023
25b222d
cleanup
TheSwerik Sep 18, 2023
f8be78c
cleanup
TheSwerik Sep 18, 2023
73f3e93
cleanup GemRepositroy
TheSwerik Sep 18, 2023
5584d4d
move class
TheSwerik Sep 18, 2023
115f9ee
man
TheSwerik Sep 18, 2023
cadc3ec
fix BackgroundJobs
TheSwerik Sep 18, 2023
0bf65ef
Cleanup Database
TheSwerik Sep 18, 2023
63b71a5
cleanup
TheSwerik Sep 18, 2023
4d10f47
cleanup
TheSwerik Sep 18, 2023
5db102b
cleanup Infrastructure & update to DotNet 8
TheSwerik Sep 18, 2023
3789c36
dotnet 8 autocleanup
TheSwerik Sep 18, 2023
c45895a
cleanup
TheSwerik Sep 18, 2023
9b20f03
Extract Extensions
TheSwerik Sep 19, 2023
d122909
update Packages and fix Tests
TheSwerik Oct 5, 2023
491f871
fix migrations
TheSwerik Oct 5, 2023
34d7ab0
fix AppDbContext
TheSwerik Oct 5, 2023
c2bcaa4
cleanup
TheSwerik Oct 5, 2023
eb8292d
add new web project
TheSwerik Oct 5, 2023
a602879
why did this fix stuff
TheSwerik Oct 5, 2023
b965319
remove web2
TheSwerik Oct 5, 2023
3f77cc0
move components
TheSwerik Oct 5, 2023
03ba26d
idk why this didnt work for Rider
TheSwerik Oct 5, 2023
b02fc40
move classes
TheSwerik Oct 5, 2023
2addf33
fix imports
TheSwerik Oct 5, 2023
02bf2b9
target blank for link
TheSwerik Oct 5, 2023
20b0d24
cleanup
TheSwerik Oct 5, 2023
de5f610
finally fixed poe.trade url bug
TheSwerik Oct 5, 2023
d3a4bdd
cleanup
TheSwerik Oct 5, 2023
b83ebff
Merge pull request #112 from TheSwerik/refactor/clean-architecture
TheSwerik Oct 5, 2023
bfbcebd
update to dotnet 8
TheSwerik Oct 5, 2023
0551b35
move stats to statistics
TheSwerik Oct 5, 2023
3e349ed
add Analytics
TheSwerik Oct 5, 2023
2109028
remove Alternate Quality
TheSwerik Dec 20, 2023
074645e
upgrade dotnet and remove FluentAssertion
TheSwerik Jul 1, 2025
05af0da
Merge branch 'fix/optimize' into feature/2.0
TheSwerik Jul 1, 2025
a263901
fix merge problems
TheSwerik Jul 1, 2025
bae315d
add ResultRepository
TheSwerik Jul 1, 2025
0c232d1
add Migration
TheSwerik Jul 1, 2025
038a7bc
fixes
TheSwerik Jul 1, 2025
ac5d003
add PoC
TheSwerik Jul 1, 2025
42c7d9b
cleanup
TheSwerik Jul 1, 2025
d18a1d8
add todo
TheSwerik Jul 1, 2025
e3026e7
asd
TheSwerik Jul 1, 2025
a53e993
hm
TheSwerik Jul 1, 2025
2bd3c9c
test again
TheSwerik Jul 1, 2025
4232a99
test
TheSwerik Jul 1, 2025
83dc213
update github actions
TheSwerik Jul 1, 2025
5f560c9
test
TheSwerik Jul 1, 2025
5fb8c32
test
TheSwerik Jul 1, 2025
c667afa
remove chart.js
TheSwerik Jul 1, 2025
ad0bfb7
test
TheSwerik Jul 1, 2025
80d1d3f
hm
TheSwerik Jul 1, 2025
af270be
change deployment method
TheSwerik Jul 1, 2025
6ee4c72
remove debug
TheSwerik Jul 1, 2025
3fdb8c3
cleanup
TheSwerik Jul 1, 2025
ebcd972
i mean it work but idk why
TheSwerik Jul 3, 2025
710aec4
cleaner
TheSwerik Jul 3, 2025
33aa137
fix mainlayout
TheSwerik Jul 3, 2025
0d854a8
it works
TheSwerik Jul 3, 2025
9fc28d4
finish analytics
TheSwerik Jul 3, 2025
09a89de
cleanup
TheSwerik Jul 3, 2025
7c8ca2c
wat
TheSwerik Jul 3, 2025
48c9232
add ApiKey for Analytics
TheSwerik Jul 3, 2025
f8eb106
cleanup
TheSwerik Jul 3, 2025
21204ed
fix css bugs
TheSwerik Jul 3, 2025
71be60f
fix css
TheSwerik Jul 3, 2025
4c2e9f6
Merge pull request #123 from TheSwerik/feature/analytics
TheSwerik Jul 3, 2025
0c0c980
split code and razor
TheSwerik Jul 4, 2025
4d10a6f
add Calculator
TheSwerik Jul 4, 2025
5a4ef6d
finish MathInput
TheSwerik Jul 4, 2025
67eb02d
this somehow works man
TheSwerik Jul 4, 2025
c2f0d24
use MathInput in GemStats
TheSwerik Jul 4, 2025
bdc2705
cleanup
TheSwerik Jul 4, 2025
be54a42
add MathInput in Filters
TheSwerik Jul 4, 2025
2466861
clenup
TheSwerik Jul 4, 2025
dc2fd80
Merge pull request #125 from TheSwerik/feature/math-input
TheSwerik Jul 4, 2025
78c5048
add API_KEY
TheSwerik Jul 4, 2025
80ba662
working LeagueFilter
TheSwerik Jul 4, 2025
4fc31fc
working league selection
TheSwerik Jul 4, 2025
1d6c881
fetch data with league
TheSwerik Jul 4, 2025
52d66f0
add League filtering in API
TheSwerik Jul 4, 2025
cf83c10
cleanup
TheSwerik Jul 4, 2025
f550a5f
fix tests
TheSwerik Jul 4, 2025
44f2534
fix test
TheSwerik Jul 4, 2025
fa45951
fix scrolltobottom
TheSwerik Jul 4, 2025
1794cc1
Merge pull request #126 from TheSwerik/feature/114-change-league
TheSwerik Jul 4, 2025
0d9a671
add (probably terrible) .editorconfig
TheSwerik Jul 4, 2025
ca419e0
fix
TheSwerik Jul 4, 2025
b0c7e42
fix Cookie
TheSwerik Jul 8, 2025
0b4326d
cleanup navbar
TheSwerik Jul 8, 2025
8f447a9
Merge pull request #129 from TheSwerik/feature/prepare-for-main
TheSwerik Jul 8, 2025
99dc95c
Merge branch 'main' into feature/2.0
TheSwerik Jul 8, 2025
51837f6
fix deployment
TheSwerik Jul 10, 2025
2188708
cleanup
TheSwerik Jul 10, 2025
8a4763c
fix new port
TheSwerik Jul 21, 2025
03a7e52
cleanup
TheSwerik Jul 21, 2025
1382457
fix add-migration
TheSwerik Jul 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "9.0.6",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}
6 changes: 4 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trigger:
- release
steps:
- name: run tests
image: mcr.microsoft.com/dotnet/sdk:7.0
image: mcr.microsoft.com/dotnet/sdk:9.0
commands:
- dotnet test
---
Expand Down Expand Up @@ -91,4 +91,6 @@ steps:
PASSWORD:
from_secret: REGISTRY_PASSWORD
POSTGRES_PASSWORD:
from_secret: POSTGRES_PASSWORD
from_secret: POSTGRES_PASSWORD
API_KEY:
from_secret: API_KEY
4,080 changes: 4,080 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

68 changes: 45 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,53 @@
name: Deploy to GitHub Pages
on:
push:
branches: [ main ]
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy-to-github-pages:
# use ubuntu-latest image to run steps on
deploy:
#TODO
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.100
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- name: Tests
run: dotnet test

- name: Publish .NET Core Project
run: dotnet publish src/Web/Web.csproj -c Debug -o release --nologo

- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll

- name: Tests
run: dotnet test
- name: Setup Pages
uses: actions/configure-pages@v5

- name: Publish .NET Core Project
run: dotnet publish src/Web/Web.csproj -c Debug -o release --nologo

- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll

- name: Commit wwwroot to GitHub Pages
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: release/wwwroot
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'release/wwwroot'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
36 changes: 19 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
name: Test

on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]

on: [ pull_request ]
jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,4 @@ MigrationBackup/

**/.idea/

# test commit
**/wwwroot/js/bundle.js*
8 changes: 8 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<PropertyGroup>
<RootNamespace>PoEGamblingHelper.$(MSBuildProjectName)</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
</Project>
7 changes: 3 additions & 4 deletions add-migration.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
$Name = Read-Host -Prompt 'Name of the migration'
dotnet ef migrations add $Name --project src/Infrastructure -s src/Api

#TODO automate major minor version updates
$Name = $args[0]
If ([string]::IsNullOrEmpty($Name)) { $Name = Read-Host -Prompt 'Name of the migration' }
dotnet ef migrations add $Name --project src/Infrastructure -s src/Api
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
environment:
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: true
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
ApiKey: $API_KEY
restart: unless-stopped
deploy:
mode: replicated
Expand Down
12 changes: 6 additions & 6 deletions src/Api/Api.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.3"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.3">
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.6"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.1"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj"/>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj"/>
<ProjectReference Include="..\Application\Application.csproj" />
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Api;
namespace PoEGamblingHelper.Api.Configuration;

public static class ConfigureCache
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Net;
using System.Threading.RateLimiting;

namespace Api;
namespace PoEGamblingHelper.Api.Configuration;

public static class ConfigureRateLimiter
{
Expand Down Expand Up @@ -62,7 +62,8 @@ private static RateLimitPartition<string> GetGlobalRateLimiter(IConfiguration co
}

private static RateLimitPartition<IPAddress> GetIpAddressRateLimiter(
IConfiguration configuration, HttpContext context)
IConfiguration configuration,
HttpContext context)
{
var remoteIpAddress = context.Connection.RemoteIpAddress;
if (IPAddress.IsLoopback(remoteIpAddress!)) return RateLimitPartition.GetNoLimiter(IPAddress.Loopback);
Expand Down
55 changes: 55 additions & 0 deletions src/Api/Controllers/AnalyticsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PoEGamblingHelper.Application.Repositories;
using PoEGamblingHelper.Application.Services;
using PoEGamblingHelper.Domain.Entity.Analytics;

namespace PoEGamblingHelper.Api.Controllers;

public class AnalyticsController(IAnalyticsDayRepository analyticsRepository, IConfiguration configuration, IDateTimeService dateTimeService)
: ApiControllerBase
{
[HttpGet]
[Authorize]
public IAsyncEnumerable<AnalyticsDay> Get([FromQuery] DateOnly? start, [FromQuery] DateOnly? end)
{
if (start is null || end is null) return analyticsRepository.GetAll();

return analyticsRepository.Get(start.Value, end.Value);
}

[HttpGet("check")]
[Authorize]
public IActionResult Check()
{
return Ok();
}

[HttpGet("login")]
public async Task<IActionResult> Login([FromHeader(Name = "Authorization")] string apiKey)
{
var apiKeySolution = configuration.GetValue<string>("ApiKey");
if (apiKey.Length <= "Bearer ".Length || !string.Equals(apiKey["Bearer ".Length..], apiKeySolution)) return Unauthorized();

var claimsIdentity = new ClaimsIdentity(
[new Claim(ClaimTypes.Name, "ApiKeyUser")],
CookieAuthenticationDefaults.AuthenticationScheme);

var authProperties = new AuthenticationProperties
{
IsPersistent = true,
ExpiresUtc = dateTimeService.UtcNow().AddDays(30),
AllowRefresh = true
};

await HttpContext.SignInAsync(
CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);

return Ok();
}
}
8 changes: 2 additions & 6 deletions src/Api/Controllers/ApiControllerBase.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Microsoft.AspNetCore.Mvc;

namespace Api.Controllers;
namespace PoEGamblingHelper.Api.Controllers;

[ApiController]
[Route("[controller]")]
public abstract class ApiControllerBase : ControllerBase
{
}
[ApiController] [Route("[controller]")] public abstract class ApiControllerBase : ControllerBase;
28 changes: 8 additions & 20 deletions src/Api/Controllers/CurrencyController.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
using Application.Services;
using Domain.Entity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OutputCaching;
using PoEGamblingHelper.Application.Repositories;
using PoEGamblingHelper.Domain.Entity;
using PoEGamblingHelper.Infrastructure;

namespace Api.Controllers;
namespace PoEGamblingHelper.Api.Controllers;

public class CurrencyController : ApiControllerBase
public class CurrencyController(ICurrencyRepository currencyRepository) : ApiControllerBase
{
private readonly IAnalyticsService _analyticsService;
private readonly IApplicationDbContextFactory _applicationDbContextFactory;

public CurrencyController(IApplicationDbContextFactory applicationDbContextFactory,
IAnalyticsService analyticsService)
{
_applicationDbContextFactory = applicationDbContextFactory;
_analyticsService = analyticsService;
}

[HttpGet]
[OutputCache(PolicyName = "FetchData")]
public async IAsyncEnumerable<Currency> GetAll()
[OutputCache(PolicyName = Constants.DataFetcherCacheTag)]
public IAsyncEnumerable<Currency> GetAll([FromQuery] string league)
{
await _analyticsService.AddView(Request.GetRealIpAddress());
using var applicationDbContext = _applicationDbContextFactory.CreateDbContext();
await foreach (var item in applicationDbContext.Currency.AsAsyncEnumerable().ConfigureAwait(false))
yield return item;
return currencyRepository.GetAll(league);
}
}
27 changes: 9 additions & 18 deletions src/Api/Controllers/GemController.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
using Application.Services;
using Domain.Entity.Gem;
using Domain.QueryParameters;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OutputCaching;
using PoEGamblingHelper.Application.QueryParameters;
using PoEGamblingHelper.Application.Repositories;
using PoEGamblingHelper.Domain.Entity.Gem;
using PoEGamblingHelper.Infrastructure;

namespace Api.Controllers;
namespace PoEGamblingHelper.Api.Controllers;

public class GemController : ApiControllerBase
public class GemController(IGemRepository gemRepository) : ApiControllerBase
{
private readonly IAnalyticsService _analyticsService;
private readonly IGemService _gemService;

public GemController(IGemService gemService, IAnalyticsService analyticsService)
{
_gemService = gemService;
_analyticsService = analyticsService;
}

[HttpGet]
[OutputCache(PolicyName = "FetchData")]
public async Task<Page<GemData>> GetAll([FromQuery] GemDataQuery? query, [FromQuery] PageRequest page)
[OutputCache(PolicyName = Constants.DataFetcherCacheTag)]
public Page<GemData> GetAll([FromQuery] GemDataQuery? query, [FromQuery] PageRequest page)
{
await _analyticsService.AddView(Request.GetRealIpAddress());
return await _gemService.GetAll(query, page);
return gemRepository.Search(query, page);
}
}
Loading