Skip to content

Commit 4546687

Browse files
committed
RE1-T118 PR#379 fixes
1 parent 13a44f5 commit 4546687

7 files changed

Lines changed: 47 additions & 2 deletions

File tree

Core/Resgrid.Model/WeatherAlertSource.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public class WeatherAlertSource : IEntity
4444

4545
public bool IsFailure { get; set; }
4646

47+
public bool IsPermanentFailure { get; set; }
48+
4749
[MaxLength(2000)]
4850
public string ErrorMessage { get; set; }
4951

Core/Resgrid.Services/WeatherAlertService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ public async Task ProcessWeatherAlertSourceAsync(Guid sourceId, CancellationToke
238238
source.LastPollUtc = DateTime.UtcNow;
239239
source.LastSuccessUtc = DateTime.UtcNow;
240240
source.IsFailure = false;
241+
source.IsPermanentFailure = false;
241242
source.ErrorMessage = null;
242243
await _weatherAlertSourceRepository.UpdateAsync(source, ct, true);
243244
}
@@ -249,6 +250,7 @@ public async Task ProcessWeatherAlertSourceAsync(Guid sourceId, CancellationToke
249250
// user edits and saves it.
250251
source.LastPollUtc = DateTime.UtcNow;
251252
source.IsFailure = true;
253+
source.IsPermanentFailure = true;
252254
source.ErrorMessage = ex.Message;
253255
await _weatherAlertSourceRepository.UpdateAsync(source, ct, true);
254256
}
@@ -281,8 +283,7 @@ public async Task ProcessAllActiveSourcesAsync(CancellationToken ct = default)
281283
{
282284
// Skip sources with permanent failures (e.g. invalid zone codes).
283285
// They will be retried only after the user edits and saves the source.
284-
if (source.IsFailure && !string.IsNullOrEmpty(source.ErrorMessage) &&
285-
!source.ErrorMessage.StartsWith("Transient:"))
286+
if (source.IsFailure && source.IsPermanentFailure)
286287
continue;
287288

288289
// Check if it's time to poll based on interval
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using FluentMigrator;
2+
3+
namespace Resgrid.Providers.Migrations.Migrations
4+
{
5+
[Migration(68)]
6+
public class M0068_AddIsPermanentFailureToWeatherAlertSources : Migration
7+
{
8+
public override void Up()
9+
{
10+
Alter.Table("WeatherAlertSources")
11+
.AddColumn("IsPermanentFailure").AsBoolean().NotNullable().WithDefaultValue(false);
12+
}
13+
14+
public override void Down()
15+
{
16+
Delete.Column("IsPermanentFailure").FromTable("WeatherAlertSources");
17+
}
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using FluentMigrator;
2+
3+
namespace Resgrid.Providers.MigrationsPg.Migrations
4+
{
5+
[Migration(68)]
6+
public class M0068_AddIsPermanentFailureToWeatherAlertSourcesPg : Migration
7+
{
8+
public override void Up()
9+
{
10+
Alter.Table("weatheralertsources")
11+
.AddColumn("ispermanentfailure").AsBoolean().NotNullable().WithDefaultValue(false);
12+
}
13+
14+
public override void Down()
15+
{
16+
Delete.Column("ispermanentfailure").FromTable("weatheralertsources");
17+
}
18+
}
19+
}

Web/Resgrid.Web.Services/Controllers/v4/WeatherAlertsController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public async Task<ActionResult<GetWeatherAlertSourcesResult>> SaveSource([FromBo
208208

209209
// Clear any previous permanent failure so the source will be retried on next poll.
210210
source.IsFailure = false;
211+
source.IsPermanentFailure = false;
211212
source.ErrorMessage = null;
212213

213214
await _weatherAlertService.SaveSourceAsync(source);
@@ -486,6 +487,7 @@ private static WeatherAlertSourceResultData MapSourceToResultData(WeatherAlertSo
486487
LastPollUtc = source.LastPollUtc?.TimeConverterToString(department),
487488
LastSuccessUtc = source.LastSuccessUtc?.TimeConverterToString(department),
488489
IsFailure = source.IsFailure,
490+
IsPermanentFailure = source.IsPermanentFailure,
489491
ErrorMessage = source.ErrorMessage
490492
};
491493
}

Web/Resgrid.Web.Services/Models/v4/WeatherAlerts/WeatherAlertSourceResultData.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class WeatherAlertSourceResultData
1414
public string LastPollUtc { get; set; }
1515
public string LastSuccessUtc { get; set; }
1616
public bool IsFailure { get; set; }
17+
public bool IsPermanentFailure { get; set; }
1718
public string ErrorMessage { get; set; }
1819
}
1920
}

Web/Resgrid.Web/Areas/User/Views/WeatherAlerts/Settings.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
areaFilter = source.AreaFilter ?? "",
166166
pollInterval = source.PollIntervalMinutes,
167167
active = source.Active,
168+
isPermanentFailure = source.IsPermanentFailure,
168169
errorMessage = source.ErrorMessage ?? ""
169170
});
170171
}

0 commit comments

Comments
 (0)