Skip to content

Commit

Permalink
Merge pull request #7 from andresharpe/fix/seed-data-admin-code-bug
Browse files Browse the repository at this point in the history
Fixed missing admin code bug
  • Loading branch information
andresharpe authored Aug 11, 2024
2 parents 2989690 + 4568f18 commit 21e4b2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions source/Cute/Commands/SeedDataCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private async Task FilterAndExtractGeos(Settings settings)

if (!nearLocations) continue;

WriteStateOrProvinveEntryIfMissing(record, csvWriter, countryToGeoId, adminCodeToGeoId);
var adminCode = WriteStateOrProvinveEntryIfMissing(record, csvWriter, countryToGeoId, adminCodeToGeoId);

var (tzStandardOffset, tzDaylightSavingOffset) = record.Timezone.ToTimeZoneOffsets();

Expand All @@ -244,7 +244,7 @@ private async Task FilterAndExtractGeos(Settings settings)
Title = $"{record.CountryName} | {record.AdminName} | {record.CityName}",
Name = record.CityName,
AlternateNames = record.CityAlternateName.Replace(',', '\u2E32').Replace('|', ','),
DataGeoParent = adminCodeToGeoId[record.AdminCode],
DataGeoParent = adminCodeToGeoId[adminCode],
GeoType = "city-or-town",
GeoSubType = string.IsNullOrEmpty(record.Capital)
? (record.PopulationProper > 10000 ? "city" : "town")
Expand Down Expand Up @@ -282,7 +282,7 @@ private async Task FilterAndExtractGeos(Settings settings)
return;
}

private static void WriteStateOrProvinveEntryIfMissing(SimplemapsGeoInput record, CsvWriter csvWriter,
private static string WriteStateOrProvinveEntryIfMissing(SimplemapsGeoInput record, CsvWriter csvWriter,
Dictionary<string, string> countryToToGeoId, Dictionary<string, string> adminCodeToGeoId)
{
var adminCode = string.IsNullOrEmpty(record.AdminCode)
Expand All @@ -295,7 +295,7 @@ private static void WriteStateOrProvinveEntryIfMissing(SimplemapsGeoInput record

if (adminCodeToGeoId.ContainsKey(adminCode))
{
return;
return adminCode;
}

var newRecord = new GeoOutputFormat()
Expand All @@ -316,6 +316,8 @@ private static void WriteStateOrProvinveEntryIfMissing(SimplemapsGeoInput record
csvWriter.NextRecord();

adminCodeToGeoId.Add(adminCode, newRecord.Id);

return adminCode;
}

public sealed class SimplemapsGeoMap : ClassMap<SimplemapsGeoInput>
Expand Down
Binary file modified tests/Cute.Tests/data/input.output.zip
Binary file not shown.

0 comments on commit 21e4b2c

Please sign in to comment.