@@ -141,13 +141,7 @@ public async Task UpdateHutsOrchestrator(
141141 {
142142 _logger . LogDebug ( "Found existing hut for id={hutId} in the database. name={HutName}" , hutId , existingHut . Name ) ;
143143 }
144-
145- if ( existingHut ? . ManuallyEdited == true )
146- {
147- _logger . LogInformation ( "Hut with ID={hutId} was manually edited. Skipping update" , hutId ) ;
148- return existingHut ;
149- }
150-
144+
151145 var httpClient = _clientFactory . CreateClient ( "HttpClient" ) ;
152146
153147 var url = string . Format ( Helpers . GetHutInfosUrlV2 , hutId ) ;
@@ -185,7 +179,7 @@ public async Task UpdateHutsOrchestrator(
185179
186180 if ( Helpers . ExcludedHutNames . Contains ( hutInfo . hutName ) )
187181 {
188- _logger . LogInformation ( "Skipping excluded hut {hutName}" , hutInfo . hutName ) ;
182+ _logger . LogInformation ( "Skipping excluded hut name {hutName}" , hutInfo . hutName ) ;
189183 if ( existingHut != null )
190184 {
191185 _logger . LogInformation ( "Deleting hut with ID={hutId} from database" , hutId ) ;
@@ -197,36 +191,43 @@ public async Task UpdateHutsOrchestrator(
197191 }
198192
199193 var hut = existingHut ?? new Hut ( ) ;
200-
201194 hut . Id = hutInfo . hutId ;
202195 hut . Enabled = hutInfo . hutUnlocked ;
203- hut . Country = hutInfo . CountryNormalized ;
204- hut . Longitude = hutInfo . Longitude ;
205- hut . Latitude = hutInfo . Latitude ;
206196 hut . Name = hutInfo . hutName ;
207197 hut . HutWebsite = hutInfo . HutWebsiteNormalized ;
208198 hut . Link = string . Format ( Helpers . HutBookingUrlV2 , hutId ) ;
209199 hut . LastUpdated = DateTime . UtcNow ;
210200 hut . Added = existingHut ? . Added ?? DateTime . UtcNow ;
211201 hut . Activated = existingHut ? . Activated ?? ( hutInfo . hutUnlocked ? DateTime . UtcNow : null ) ;
212- hut . Altitude = hutInfo . AltitudeInt ;
213-
214- if ( hut . Latitude == null || hut . Longitude == null || ! Helpers . CoordinatesSanityCheck ( hut . Longitude . Value , hut . Latitude . Value ) )
202+
203+ if ( existingHut ? . ManuallyEdited == true )
215204 {
216- _logger . LogInformation ( "Hut with ID={hutId} has no or unrealistic coordinates. Trying to look up hut online" , hutId ) ;
217- var coordinates = await Helpers . SearchHutCoordinates ( hutInfo . hutName , httpClient , _logger ) ;
218-
219- hut . Latitude = coordinates . latitude ?? existingHut ? . Latitude ;
220- hut . Longitude = coordinates . longitude ?? existingHut ? . Longitude ;
205+ _logger . LogInformation ( "Hut with ID={hutId} was manually edited. Not updating location information" , hutId ) ;
221206 }
222-
223- if ( hut is { Latitude : not null , Longitude : not null } )
207+ else
224208 {
225- var ( country , region ) = await Helpers . GetCountryAndRegion ( hut . Latitude . Value , hut . Longitude . Value , httpClient , _logger ) ;
226- if ( country != null )
227- hut . Country = country ;
228- if ( region != null )
229- hut . Region = region ;
209+ hut . Country = hutInfo . CountryNormalized ;
210+ hut . Altitude = hutInfo . AltitudeInt ;
211+ hut . Longitude = hutInfo . Longitude ;
212+ hut . Latitude = hutInfo . Latitude ;
213+
214+ if ( hut . Latitude == null || hut . Longitude == null || ! Helpers . CoordinatesSanityCheck ( hut . Longitude . Value , hut . Latitude . Value ) )
215+ {
216+ _logger . LogInformation ( "Hut with ID={hutId} has no or unrealistic coordinates. Trying to look up hut online" , hutId ) ;
217+ var coordinates = await Helpers . SearchHutCoordinates ( hutInfo . hutName , httpClient , _logger ) ;
218+
219+ hut . Latitude = coordinates . latitude ?? existingHut ? . Latitude ;
220+ hut . Longitude = coordinates . longitude ?? existingHut ? . Longitude ;
221+ }
222+
223+ if ( hut is { Latitude : not null , Longitude : not null } )
224+ {
225+ var ( country , region ) = await Helpers . GetCountryAndRegion ( hut . Latitude . Value , hut . Longitude . Value , httpClient , _logger ) ;
226+ if ( country != null )
227+ hut . Country = country ;
228+ if ( region != null )
229+ hut . Region = region ;
230+ }
230231 }
231232
232233 if ( existingHut == null )
0 commit comments