Skip to content

Commit 2fa2f8c

Browse files
authored
Merge pull request #51 from Kromtec/develop
Develop
2 parents 2d0274d + 6cd44ce commit 2fa2f8c

40 files changed

+3433
-1203
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish osx-arm64
2+
3+
on:
4+
workflow_dispatch: # This allows manual triggering from the Actions tab.
5+
6+
jobs:
7+
build:
8+
runs-on: macos-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Setup Node.js
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: '18.x'
16+
17+
- name: Setup .NET Core
18+
uses: actions/setup-dotnet@v4
19+
with:
20+
dotnet-version: '8.0.x'
21+
22+
- name: Restore dependencies
23+
run: dotnet restore LegendsViewer.sln
24+
25+
- name: Build Backend and Frontend (Vue 3)
26+
run: dotnet build LegendsViewer.sln --configuration Release --no-restore
27+
28+
- name: Publish Backend
29+
run: dotnet publish LegendsViewer.Backend/LegendsViewer.Backend.csproj -c Release -r osx-arm64 --self-contained true -p:PublishSingleFile=true -p:DebugType=none -o ./publish
30+
31+
- name: Publish Frontend
32+
run: dotnet publish LegendsViewer.Frontend/LegendsViewer.Frontend.csproj -c Release -r osx-arm64 -p:DebugType=none -o ./publish
33+
34+
- name: Sign and Create ZIP Archive
35+
env:
36+
MACOS_DEVELOPER_ID: ${{ secrets.MACOS_DEVELOPER_ID }}
37+
MACOS_APPSTORE_APP_PASSWORD: ${{ secrets.MACOS_APPSTORE_APP_PASSWORD }}
38+
MACOS_CERTIFICATE_P12: ${{ secrets.MACOS_CERTIFICATE_P12 }}
39+
run: .github/scripts/signmacos.sh
40+
41+
- name: Upload artifact
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: LegendsViewer-osx-arm64
45+
path: ./release/LegendsViewer*.dmg

LegendsViewer.Backend/Controllers/WorldController.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using LegendsViewer.Backend.Contracts;
22
using LegendsViewer.Backend.Extensions;
3+
using LegendsViewer.Backend.Legends;
34
using LegendsViewer.Backend.Legends.Interfaces;
45
using LegendsViewer.Backend.Legends.Maps;
56
using Microsoft.AspNetCore.Mvc;
@@ -103,8 +104,6 @@ public ActionResult<PaginatedResponse<WorldObjectDto>> GetEventCollections(
103104

104105
[HttpGet("eventchart")]
105106
[ProducesResponseType(StatusCodes.Status200OK)]
106-
[ProducesResponseType(StatusCodes.Status400BadRequest)]
107-
[ProducesResponseType(StatusCodes.Status404NotFound)]
108107
public ActionResult<ChartDataDto> GetEventChart()
109108
{
110109
var response = new ChartDataDto();
@@ -140,4 +139,30 @@ public ActionResult<ChartDataDto> GetEventChart()
140139
response.Datasets.Add(dataset);
141140
return Ok(response);
142141
}
142+
143+
[HttpGet("eventtypechart")]
144+
[ProducesResponseType(StatusCodes.Status200OK)]
145+
public ActionResult<ChartDataDto> GetEventTypeChart()
146+
{
147+
var response = new ChartDataDto();
148+
var dataset = new ChartDatasetDto
149+
{
150+
Label = "Occurrences per Event Type"
151+
};
152+
153+
// Group by type and count events per type
154+
var eventCounts = _worldDataService.Events
155+
.GroupBy(e => e.Type)
156+
.ToDictionary(g => g.Key, g => g.Count());
157+
158+
// Output the results (sorted by count)
159+
foreach (var eventItem in eventCounts.OrderByDescending(kv => kv.Value))
160+
{
161+
response.Labels.Add($"{WorldEventExtensions.GetEventInfo(eventItem.Key)} ({eventItem.Key}) {eventItem.Value,10}");
162+
dataset.Data.Add(eventItem.Value);
163+
}
164+
165+
response.Datasets.Add(dataset);
166+
return Ok(response);
167+
}
143168
}
Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,154 @@
11
using LegendsViewer.Backend.Legends.WorldObjects;
22
using Microsoft.AspNetCore.Mvc;
3-
using LegendsViewer.Backend.Legends.Interfaces;
43
using LegendsViewer.Backend.Legends.EventCollections;
5-
using LegendsViewer.Backend.Legends.Events;
4+
using LegendsViewer.Backend.DataAccess.Repositories.Interfaces;
65

76
namespace LegendsViewer.Backend.Controllers;
87

9-
public class DanceFormController(IWorld worldDataService) : WorldObjectGenericController<DanceForm>(worldDataService.DanceForms, worldDataService.GetDanceForm)
8+
public class DanceFormController(IWorldObjectRepository<DanceForm> repository) : WorldObjectGenericController<DanceForm>(repository)
109
{
1110
}
1211

13-
public class MusicalFormController(IWorld worldDataService) : WorldObjectGenericController<MusicalForm>(worldDataService.MusicalForms, worldDataService.GetMusicalForm)
12+
public class MusicalFormController(IWorldObjectRepository<MusicalForm> repository) : WorldObjectGenericController<MusicalForm>(repository)
1413
{
1514
}
1615

17-
public class PoeticFormController(IWorld worldDataService) : WorldObjectGenericController<PoeticForm>(worldDataService.PoeticForms, worldDataService.GetPoeticForm)
16+
public class PoeticFormController(IWorldObjectRepository<PoeticForm> repository) : WorldObjectGenericController<PoeticForm>(repository)
1817
{
1918
}
2019

21-
public class WrittenContentController(IWorld worldDataService) : WorldObjectGenericController<WrittenContent>(worldDataService.WrittenContents, worldDataService.GetWrittenContent)
20+
public class WrittenContentController(IWorldObjectRepository<WrittenContent> repository) : WorldObjectGenericController<WrittenContent>(repository)
2221
{
2322
}
2423

25-
public class LandmassController(IWorld worldDataService) : WorldObjectGenericController<Landmass>(worldDataService.Landmasses, worldDataService.GetLandmass)
24+
public class LandmassController(IWorldObjectRepository<Landmass> repository) : WorldObjectGenericController<Landmass>(repository)
2625
{
2726
}
2827

29-
public class RiverController(IWorld worldDataService) : WorldObjectGenericController<River>(worldDataService.Rivers, worldDataService.GetRiver)
28+
public class RiverController(IWorldObjectRepository<River> repository) : WorldObjectGenericController<River>(repository)
3029
{
3130
}
3231

33-
public class SiteController(IWorld worldDataService) : WorldObjectGenericController<Site>(worldDataService.Sites, worldDataService.GetSite)
32+
public class SiteController(IWorldObjectRepository<Site> repository) : WorldObjectGenericController<Site>(repository)
3433
{
3534
}
3635

37-
public class RegionController(IWorld worldDataService) : WorldObjectGenericController<WorldRegion>(worldDataService.Regions, worldDataService.GetRegion)
36+
public class RegionController(IWorldObjectRepository<WorldRegion> repository) : WorldObjectGenericController<WorldRegion>(repository)
3837
{
3938
}
4039

41-
public class UndergroundRegionController(IWorld worldDataService) : WorldObjectGenericController<UndergroundRegion>(worldDataService.UndergroundRegions, worldDataService.GetUndergroundRegion)
40+
public class UndergroundRegionController(IWorldObjectRepository<UndergroundRegion> repository) : WorldObjectGenericController<UndergroundRegion>(repository)
4241
{
4342
}
4443

45-
public class ArtifactController(IWorld worldDataService) : WorldObjectGenericController<Artifact>(worldDataService.Artifacts, worldDataService.GetArtifact)
44+
public class ArtifactController(IWorldObjectRepository<Artifact> repository) : WorldObjectGenericController<Artifact>(repository)
4645
{
4746
}
4847

49-
public class EntityController(IWorld worldDataService) : WorldObjectGenericController<Entity>(worldDataService.Entities, worldDataService.GetEntity)
48+
public class EntityController(IWorldObjectRepository<Entity> repository) : WorldObjectGenericController<Entity>(repository)
5049
{
5150
[HttpGet("civs")]
5251
[ProducesResponseType(StatusCodes.Status200OK)]
5352
public ActionResult<List<Entity>> GetMainCivilizations()
5453
{
55-
return Ok(AllElements.Where(x => x.IsCiv || (x.EntityType == Legends.Enums.EntityType.Civilization && x.SiteHistory.Count > 0)));
54+
return Ok(Repository.GetAllElements().Where(x => x.IsCiv || (x.EntityType == Legends.Enums.EntityType.Civilization && x.SiteHistory.Count > 0)));
5655
}
5756
}
5857

59-
public class HistoricalFigureController(IWorld worldDataService) : WorldObjectGenericController<HistoricalFigure>(worldDataService.HistoricalFigures, worldDataService.GetHistoricalFigure)
58+
public class HistoricalFigureController(IWorldObjectRepository<HistoricalFigure> repository) : WorldObjectGenericController<HistoricalFigure>(repository)
6059
{
6160
}
6261

63-
public class MountainPeakController(IWorld worldDataService) : WorldObjectGenericController<MountainPeak>(worldDataService.MountainPeaks, worldDataService.GetMountainPeak)
62+
public class MountainPeakController(IWorldObjectRepository<MountainPeak> repository) : WorldObjectGenericController<MountainPeak>(repository)
6463
{
6564
}
6665

67-
public class StructureController(IWorld worldDataService) : WorldObjectGenericController<Structure>(worldDataService.Structures, worldDataService.GetStructure)
66+
public class StructureController(IWorldObjectRepository<Structure> repository) : WorldObjectGenericController<Structure>(repository)
6867
{
6968
}
7069

71-
public class ConstructionController(IWorld worldDataService) : WorldObjectGenericController<WorldConstruction>(worldDataService.WorldConstructions, worldDataService.GetWorldConstruction)
70+
public class ConstructionController(IWorldObjectRepository<WorldConstruction> repository) : WorldObjectGenericController<WorldConstruction>(repository)
7271
{
7372
}
7473

75-
public class EraController(IWorld worldDataService) : WorldObjectGenericController<Era>(worldDataService.Eras, worldDataService.GetEra)
74+
public class EraController(IWorldObjectRepository<Era> repository) : WorldObjectGenericController<Era>(repository)
7675
{
7776
}
7877

7978
// Warfare
8079

81-
public class WarController(IWorld worldDataService) : WorldObjectGenericController<War>(worldDataService.Wars, worldDataService.GetEventCollection<War>)
80+
public class WarController(IWorldObjectRepository<War> repository) : WorldObjectGenericController<War>(repository)
8281
{
8382
}
8483

85-
public class BattleController(IWorld worldDataService) : WorldObjectGenericController<Battle>(worldDataService.Battles, worldDataService.GetEventCollection<Battle>)
84+
public class BattleController(IWorldObjectRepository<Battle> repository) : WorldObjectGenericController<Battle>(repository)
8685
{
8786
}
8887

89-
public class DuelController(IWorld worldDataService) : WorldObjectGenericController<Duel>(worldDataService.Duels, worldDataService.GetEventCollection<Duel>)
88+
public class DuelController(IWorldObjectRepository<Duel> repository) : WorldObjectGenericController<Duel>(repository)
9089
{
9190
}
9291

93-
public class RaidController(IWorld worldDataService) : WorldObjectGenericController<Raid>(worldDataService.Raids, worldDataService.GetEventCollection<Raid>)
92+
public class RaidController(IWorldObjectRepository<Raid> repository) : WorldObjectGenericController<Raid>(repository)
9493
{
9594
}
9695

97-
public class SiteConqueredController(IWorld worldDataService) : WorldObjectGenericController<SiteConquered>(worldDataService.SiteConquerings, worldDataService.GetEventCollection<SiteConquered>)
96+
public class SiteConqueredController(IWorldObjectRepository<SiteConquered> repository) : WorldObjectGenericController<SiteConquered>(repository)
9897
{
9998
}
10099

101100
// Politcal Conflicts
102101

103-
public class InsurrectionController(IWorld worldDataService) : WorldObjectGenericController<Insurrection>(worldDataService.Insurrections, worldDataService.GetEventCollection<Insurrection>)
102+
public class InsurrectionController(IWorldObjectRepository<Insurrection> repository) : WorldObjectGenericController<Insurrection>(repository)
104103
{
105104
}
106105

107-
public class PersecutionController(IWorld worldDataService) : WorldObjectGenericController<Persecution>(worldDataService.Persecutions, worldDataService.GetEventCollection<Persecution>)
106+
public class PersecutionController(IWorldObjectRepository<Persecution> repository) : WorldObjectGenericController<Persecution>(repository)
108107
{
109108
}
110109

111-
public class PurgeController(IWorld worldDataService) : WorldObjectGenericController<Purge>(worldDataService.Purges, worldDataService.GetEventCollection<Purge>)
110+
public class PurgeController(IWorldObjectRepository<Purge> repository) : WorldObjectGenericController<Purge>(repository)
112111
{
113112
}
114113

115-
public class CoupController(IWorld worldDataService) : WorldObjectGenericController<EntityOverthrownCollection>(worldDataService.Coups, worldDataService.GetEventCollection<EntityOverthrownCollection>)
114+
public class CoupController(IWorldObjectRepository<EntityOverthrownCollection> repository) : WorldObjectGenericController<EntityOverthrownCollection>(repository)
116115
{
117116
}
118117

119-
public class BeastAttackController(IWorld worldDataService) : WorldObjectGenericController<BeastAttack>(worldDataService.BeastAttacks, worldDataService.GetEventCollection<BeastAttack>)
118+
public class BeastAttackController(IWorldObjectRepository<BeastAttack> repository) : WorldObjectGenericController<BeastAttack>(repository)
120119
{
121120
}
122121

123-
public class AbductionController(IWorld worldDataService) : WorldObjectGenericController<Abduction>(worldDataService.Abductions, worldDataService.GetEventCollection<Abduction>)
122+
public class AbductionController(IWorldObjectRepository<Abduction> repository) : WorldObjectGenericController<Abduction>(repository)
124123
{
125124
}
126125

127-
public class TheftController(IWorld worldDataService) : WorldObjectGenericController<Theft>(worldDataService.Thefts, worldDataService.GetEventCollection<Theft>)
126+
public class TheftController(IWorldObjectRepository<Theft> repository) : WorldObjectGenericController<Theft>(repository)
128127
{
129128
}
130129

131130
// Rituals
132131

133-
public class ProcessionController(IWorld worldDataService) : WorldObjectGenericController<ProcessionCollection>(worldDataService.Processions, worldDataService.GetEventCollection<ProcessionCollection>)
132+
public class ProcessionController(IWorldObjectRepository<ProcessionCollection> repository) : WorldObjectGenericController<ProcessionCollection>(repository)
134133
{
135134
}
136135

137-
public class PerformanceController(IWorld worldDataService) : WorldObjectGenericController<PerformanceCollection>(worldDataService.Performances, worldDataService.GetEventCollection<PerformanceCollection>)
136+
public class PerformanceController(IWorldObjectRepository<PerformanceCollection> repository) : WorldObjectGenericController<PerformanceCollection>(repository)
138137
{
139138
}
140139

141-
public class JourneyController(IWorld worldDataService) : WorldObjectGenericController<Journey>(worldDataService.Journeys, worldDataService.GetEventCollection<Journey>)
140+
public class JourneyController(IWorldObjectRepository<Journey> repository) : WorldObjectGenericController<Journey>(repository)
142141
{
143142
}
144143

145-
public class CompetitionController(IWorld worldDataService) : WorldObjectGenericController<CompetitionCollection>(worldDataService.Competitions, worldDataService.GetEventCollection<CompetitionCollection>)
144+
public class CompetitionController(IWorldObjectRepository<CompetitionCollection> repository) : WorldObjectGenericController<CompetitionCollection>(repository)
146145
{
147146
}
148147

149-
public class CeremonyController(IWorld worldDataService) : WorldObjectGenericController<CeremonyCollection>(worldDataService.Ceremonies, worldDataService.GetEventCollection<CeremonyCollection>)
148+
public class CeremonyController(IWorldObjectRepository<CeremonyCollection> repository) : WorldObjectGenericController<CeremonyCollection>(repository)
150149
{
151150
}
152151

153-
public class OccasionController(IWorld worldDataService) : WorldObjectGenericController<Occasion>(worldDataService.Occasions, worldDataService.GetEventCollection<Occasion>)
152+
public class OccasionController(IWorldObjectRepository<Occasion> repository) : WorldObjectGenericController<Occasion>(repository)
154153
{
155154
}

0 commit comments

Comments
 (0)