-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented species extraction to JSON and CSV. (#7)
- Loading branch information
Showing
28 changed files
with
737 additions
and
2 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,18 @@ | ||
name: Build PokéData Solution | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Build PokéData Solution | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build Docker Image | ||
run: docker build . -t francispion.azurecr.io/pokedata:${{ github.sha }} -f src/PokeData.ETL/Dockerfile |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. | ||
|
||
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base | ||
USER app | ||
WORKDIR /app | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
ARG BUILD_CONFIGURATION=Release | ||
WORKDIR /src | ||
COPY ["src/PokeData.ETL/PokeData.ETL.csproj", "src/PokeData.ETL/"] | ||
RUN dotnet restore "./src/PokeData.ETL/./PokeData.ETL.csproj" | ||
COPY . . | ||
WORKDIR "/src/src/PokeData.ETL" | ||
RUN dotnet build "./PokeData.ETL.csproj" -c $BUILD_CONFIGURATION -o /app/build | ||
|
||
FROM build AS publish | ||
ARG BUILD_CONFIGURATION=Release | ||
RUN dotnet publish "./PokeData.ETL.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "PokeData.ETL.dll"] |
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,23 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PokeData.ETL.Entities; | ||
|
||
internal class Generation | ||
{ | ||
public int Number { get; set; } | ||
|
||
public string UniqueName { get; set; } = string.Empty; | ||
public string? DisplayName { get; set; } | ||
|
||
public Region? Region { get; set; } | ||
|
||
[JsonIgnore] | ||
public List<PokemonSpecies> Species { get; set; } = []; | ||
|
||
public static Generation FromModel(Models.Generation model, string languageName) => new() | ||
{ | ||
Number = model.Id, | ||
UniqueName = model.Name, | ||
DisplayName = model.Names.SingleOrDefault(name => name.Language?.Name == languageName)?.Value | ||
}; | ||
} |
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,45 @@ | ||
namespace PokeData.ETL.Entities; | ||
|
||
internal class PokemonSpecies | ||
{ | ||
public ushort Number { get; set; } | ||
public int Order { get; set; } | ||
|
||
public string UniqueName { get; set; } = string.Empty; | ||
public string? DisplayName { get; set; } | ||
public string? Category { get; set; } | ||
|
||
public double? GenderRatio { get; set; } | ||
public byte CatchRate { get; set; } | ||
|
||
public byte HatchTime { get; set; } | ||
|
||
public byte BaseFriendship { get; set; } | ||
|
||
public bool IsBaby { get; set; } | ||
public bool IsLegendary { get; set; } | ||
public bool IsMythical { get; set; } | ||
public bool HasGenderDifferences { get; set; } | ||
public bool CanSwitchForm { get; set; } | ||
|
||
public Generation? Generation { get; set; } | ||
public List<PokemonVariety> Varieties { get; set; } = []; | ||
|
||
public static PokemonSpecies FromModel(Models.PokemonSpecies model, string languageName) => new() | ||
{ | ||
Number = (ushort)model.Id, | ||
Order = model.Order, | ||
UniqueName = model.Name, | ||
DisplayName = model.Names.SingleOrDefault(name => name.Language?.Name == languageName)?.Value, | ||
Category = model.Genera.SingleOrDefault(genus => genus.Language?.Name == languageName)?.Value, | ||
GenderRatio = model.GenderRate == -1 ? null : (1 - model.GenderRate / 8.0), | ||
CatchRate = (byte)model.CaptureRate, | ||
HatchTime = (byte?)model.HatchCounter ?? 0, | ||
BaseFriendship = (byte?)model.BaseHappiness ?? 0, | ||
IsBaby = model.IsBaby, | ||
IsLegendary = model.IsLegendary, | ||
IsMythical = model.IsMythical, | ||
HasGenderDifferences = model.HasGenderDifferences, | ||
CanSwitchForm = model.FormsSwitchable | ||
}; | ||
} |
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,16 @@ | ||
namespace PokeData.ETL.Entities; | ||
|
||
internal class PokemonType | ||
{ | ||
public int Number { get; set; } | ||
|
||
public string UniqueName { get; set; } = string.Empty; | ||
public string? DisplayName { get; set; } | ||
|
||
public static PokemonType FromModel(Models.Type model, string languageName) => new() | ||
{ | ||
Number = model.Id, | ||
UniqueName = model.Name, | ||
DisplayName = model.Names.SingleOrDefault(name => name.Language?.Name == languageName)?.Value | ||
}; | ||
} |
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,34 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PokeData.ETL.Entities; | ||
|
||
internal class PokemonVariety | ||
{ | ||
public int Number { get; set; } | ||
public int Order { get; set; } | ||
|
||
public bool IsDefault { get; set; } | ||
|
||
public string UniqueName { get; set; } = string.Empty; | ||
|
||
public double Height { get; set; } | ||
public double Weight { get; set; } | ||
|
||
public ushort BaseExperienceYield { get; set; } | ||
|
||
public List<PokemonType> Types { get; set; } = []; | ||
|
||
[JsonIgnore] | ||
public PokemonSpecies? Species { get; set; } | ||
|
||
public static PokemonVariety FromModel(Models.Pokemon model) => new() | ||
{ | ||
Number = model.Id, | ||
Order = model.Order, | ||
IsDefault = model.IsDefault, | ||
UniqueName = model.Name, | ||
Height = model.Height / 10.0, | ||
Weight = model.Weight / 10.0, | ||
BaseExperienceYield = (ushort?)model.BaseExperience ?? 0 | ||
}; | ||
} |
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,21 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PokeData.ETL.Entities; | ||
|
||
internal class Region | ||
{ | ||
public int Number { get; set; } | ||
|
||
public string UniqueName { get; set; } = string.Empty; | ||
public string? DisplayName { get; set; } | ||
|
||
[JsonIgnore] | ||
public Generation? Generation { get; set; } | ||
|
||
public static Region FromModel(Models.Region model, string languageName) => new() | ||
{ | ||
Number = model.Id, | ||
UniqueName = model.Name, | ||
DisplayName = model.Names.SingleOrDefault(name => name.Language?.Name == languageName)?.Value | ||
}; | ||
} |
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,9 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PokeData.ETL.Models; | ||
|
||
internal record APIResource | ||
{ | ||
[JsonPropertyName("url")] | ||
public string Url { get; set; } = string.Empty; | ||
} |
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,25 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PokeData.ETL.Models; | ||
|
||
internal record Generation | ||
{ | ||
[JsonPropertyName("id")] | ||
public int Id { get; set; } | ||
|
||
[JsonPropertyName("name")] | ||
public string Name { get; set; } = string.Empty; | ||
|
||
// TODO(fpion): abilities | ||
|
||
[JsonPropertyName("names")] | ||
public List<Name> Names { get; set; } = []; | ||
|
||
[JsonPropertyName("main_region")] | ||
public NamedAPIResource? MainRegion { get; set; } | ||
|
||
// TODO(fpion): moves | ||
// TODO(fpion): pokemon_species | ||
// TODO(fpion): types | ||
// TODO(fpion): version_groups | ||
} |
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,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PokeData.ETL.Models; | ||
|
||
internal record Genus | ||
{ | ||
[JsonPropertyName("genus")] | ||
public string Value { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("language")] | ||
public NamedAPIResource? Language { get; set; } | ||
} |
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,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PokeData.ETL.Models; | ||
|
||
internal record Name | ||
{ | ||
[JsonPropertyName("name")] | ||
public string Value { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("language")] | ||
public NamedAPIResource? Language { get; set; } | ||
} |
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,9 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PokeData.ETL.Models; | ||
|
||
internal record NamedAPIResource : APIResource | ||
{ | ||
[JsonPropertyName("name")] | ||
public string Name { get; set; } = string.Empty; | ||
} |
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,44 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PokeData.ETL.Models; | ||
|
||
internal class Pokemon | ||
{ | ||
[JsonPropertyName("id")] | ||
public int Id { get; set; } | ||
|
||
[JsonPropertyName("name")] | ||
public string Name { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("base_experience")] | ||
public int? BaseExperience { get; set; } | ||
|
||
[JsonPropertyName("height")] | ||
public int Height { get; set; } | ||
|
||
[JsonPropertyName("is_default")] | ||
public bool IsDefault { get; set; } | ||
|
||
[JsonPropertyName("order")] | ||
public int Order { get; set; } | ||
|
||
[JsonPropertyName("weight")] | ||
public int Weight { get; set; } | ||
|
||
// TODO(fpion): abilities | ||
// TODO(fpion): forms | ||
// TODO(fpion): game_indices | ||
// TODO(fpion): held_items | ||
// TODO(fpion): location_area_encounters | ||
// TODO(fpion): moves | ||
// TODO(fpion): past_types | ||
// TODO(fpion): sprites | ||
|
||
[JsonPropertyName("species")] | ||
public NamedAPIResource? Species { get; set; } | ||
|
||
// TODO(fpion): stats | ||
|
||
[JsonPropertyName("types")] | ||
public List<PokemonType> Types { get; set; } = []; | ||
} |
Oops, something went wrong.