Skip to content

Commit 5da14ad

Browse files
committed
minoer changes to evenrts and program file. will restructure cron service later
1 parent fad8737 commit 5da14ad

File tree

5 files changed

+18
-92
lines changed

5 files changed

+18
-92
lines changed

src/RandomAPI/APIServices/ServiceInterfaces/ICronScheduledTask.cs

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -15,87 +15,4 @@ public interface ICronScheduledTask
1515
/// Examples: "Daily@08:30", "Monday@08:30", "Sunday@00:00"
1616
/// </summary>
1717
string Schedule { get; }
18-
19-
/// <summary>
20-
/// Executes the scheduled job logic.
21-
/// </summary>
22-
Task ExecuteAsync();
23-
}
24-
25-
26-
/// <summary>
27-
/// A daily scheduled task for routine maintenance (e.g., database cleanup, log rotation).
28-
/// Runs every day at 04:00 AM UTC.
29-
/// </summary>
30-
public class DailyMaintenanceTask : ICronScheduledTask
31-
{
32-
private readonly ILogger<DailyMaintenanceTask> _logger;
33-
34-
public DailyMaintenanceTask(ILogger<DailyMaintenanceTask> logger)
35-
{
36-
_logger = logger;
37-
}
38-
39-
// --- ICronScheduledTask Implementation ---
40-
public string Name => "Daily Maintenance & Cleanup";
41-
public string Schedule => "Daily@04:00"; // Run every day at 4:00 AM UTC
42-
// ----------------------------------------
43-
44-
public async Task ExecuteAsync()
45-
{
46-
_logger.LogInformation("Executing Daily Maintenance Task: Running routine cleanup.");
47-
48-
// --- Actual Scheduled Logic ---
49-
await Task.Delay(100); // Simulate asynchronous database cleanup or file deletion
50-
// Note: For a real cleanup task, you would inject and use a repository here.
51-
// ------------------------------
52-
53-
_logger.LogInformation("Daily Maintenance Task completed successfully.");
54-
}
55-
}
56-
57-
/// <summary>
58-
/// Scheduled task for generating a report every Monday morning.
59-
/// </summary>
60-
public class BiWeeklyReportTaskMonday : ICronScheduledTask
61-
{
62-
private readonly ILogger<BiWeeklyReportTaskMonday> _logger;
63-
64-
public BiWeeklyReportTaskMonday(ILogger<BiWeeklyReportTaskMonday> logger)
65-
{
66-
_logger = logger;
67-
}
68-
69-
public string Name => "Bi-Weekly Report (Monday)";
70-
public string Schedule => "Monday@08:30"; // Run every Monday at 8:30 AM UTC
71-
72-
public async Task ExecuteAsync()
73-
{
74-
_logger.LogInformation("Executing Monday Report Task: Compiling weekly progress report.");
75-
await Task.Delay(100); // Simulate report generation
76-
_logger.LogInformation("Monday Report Task completed successfully.");
77-
}
78-
}
79-
80-
/// <summary>
81-
/// Scheduled task for generating a report every Friday morning.
82-
/// </summary>
83-
public class BiWeeklyReportTaskFriday : ICronScheduledTask
84-
{
85-
private readonly ILogger<BiWeeklyReportTaskFriday> _logger;
86-
87-
public BiWeeklyReportTaskFriday(ILogger<BiWeeklyReportTaskFriday> logger)
88-
{
89-
_logger = logger;
90-
}
91-
92-
public string Name => "Bi-Weekly Report (Friday)";
93-
public string Schedule => "Friday@08:30"; // Run every Friday at 8:30 AM UTC
94-
95-
public async Task ExecuteAsync()
96-
{
97-
_logger.LogInformation("Executing Friday Report Task: Compiling end-of-week summary report.");
98-
await Task.Delay(100); // Simulate report generation
99-
_logger.LogInformation("Friday Report Task completed successfully.");
100-
}
10118
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace RandomAPI.Controllers
4+
{
5+
[ApiController]
6+
[Route("api/[controller]")]
7+
public class APIHealthController : ControllerBase
8+
{
9+
[HttpPost("calculate")]
10+
public IActionResult Health()
11+
{
12+
return Ok();
13+
}
14+
}
15+
}

src/RandomAPI/Models/Event.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public Event(
3131
}
3232

3333
/// <summary>
34-
/// Creates a new event, auto-generating Timestamp and content-based EventId.
34+
/// Creates a new event, auto-generating Timestamp and Content-based EventId.
3535
/// </summary>
3636
public Event(string service, string type, string jsonData, string dataType = "JSON")
3737
{

src/RandomAPI/Program.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,7 @@
3535
builder.Services.AddScoped<IWebhookRepository, WebhookRepository>();
3636

3737
// CRON schjeduled services
38-
builder.Services.AddHostedService<CronTaskRunnerService>();
39-
// Register all tasks as Scoped
40-
// Schedule 1: Once a day at 4:00 AM (Schedule: "Daily@04:00")
41-
builder.Services.AddScoped<ICronScheduledTask, DailyMaintenanceTask>();
42-
// Schedule 2: Monday and Friday mornings @ 8:30 AM (Schedule: "Monday@08:30" and "Friday@08:30")
43-
builder.Services.AddScoped<ICronScheduledTask, BiWeeklyReportTaskMonday>();
44-
builder.Services.AddScoped<ICronScheduledTask, BiWeeklyReportTaskFriday>();
38+
builder.Services.AddHostedService<CronTaskRunnerService>();//needs to be completely redone. use a db and store those things.
4539

4640

4741
#endregion

src/RandomAPI/Repository/IEventRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public interface IEventRepository
99
{
1010
/// <summary>
1111
/// Attempts to add a new Event record to the database.
12-
/// Throws an exception if the EventId (based on content hash) already exists.
12+
/// Throws an exception if the EventId (based on Content hash) already exists.
1313
/// </summary>
1414
/// <param name="eventModel">The new Event object to insert.</param>
1515
/// <returns>The ID (surrogate key) of the newly inserted record.</returns>

0 commit comments

Comments
 (0)