Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.cs]
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion

[*.{json,yml,yaml}]
indent_size = 2
14 changes: 9 additions & 5 deletions Background/VehicleRetentionCleanupService.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using TransitAnalyticsAPI.Models.Entities;
using TransitAnalyticsAPI.Services;

namespace TransitAnalyticsAPI.Background;
Expand All @@ -9,13 +10,16 @@ public class VehicleRetentionCleanupService : BackgroundService

private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly ILogger<VehicleRetentionCleanupService> _logger;
private readonly ISystemLogService<VehicleRetentionCleanupService> _systemLog;

public VehicleRetentionCleanupService(
IServiceScopeFactory serviceScopeFactory,
ILogger<VehicleRetentionCleanupService> logger)
ILogger<VehicleRetentionCleanupService> logger,
ISystemLogService<VehicleRetentionCleanupService> systemLogService)
{
_serviceScopeFactory = serviceScopeFactory;
_logger = logger;
_systemLog = systemLogService;
}

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
Expand Down Expand Up @@ -52,17 +56,17 @@ private async Task RunCleanupAsync(CancellationToken cancellationToken)

var deletedCount = await retentionService.DeleteExpiredAsync(cancellationToken);

_logger.LogInformation(
"Vehicle retention cleanup completed. Deleted {DeletedCount} expired vehicle positions.",
deletedCount);
await _systemLog.LogAsync(SystemLogType.Info, "Vehicle retention cleanup completed",
$"Deleted {deletedCount} expired vehicle positions.", cancellationToken);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception exception)
{
_logger.LogError(exception, "Vehicle retention cleanup failed.");
await _systemLog.LogAsync(SystemLogType.Error, "Vehicle retention cleanup failed", exception.ToString(),
cancellationToken);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Configuration/VehicleOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public class VehicleOptions

public int LatestPositionMaxAgeMinutes { get; set; } = 5;

public int HistoryRetentionDays { get; set; } = 7;
public int HistoryRetentionDays { get; set; } = 3;
}
2 changes: 1 addition & 1 deletion Migrations/20260315044948_InitialCreate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

Expand Down
2 changes: 1 addition & 1 deletion Migrations/20260316031315_AddGtfsRoutesAndTrips.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

Expand Down
2 changes: 1 addition & 1 deletion Migrations/20260317103126_AddGtfsRouteShapesAndStops.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable
Expand Down
2 changes: 1 addition & 1 deletion Migrations/20260321052221_AddAdminSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable
Expand Down
2 changes: 1 addition & 1 deletion Migrations/20260321063732_AddAdminGtfsUploadStatus.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable
Expand Down
2 changes: 1 addition & 1 deletion Migrations/20260321064017_AddAdminPollingToggle.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

Expand Down
Loading
Loading