Skip to content

Commit

Permalink
Merge pull request #168 from mark-szabo/v2.4
Browse files Browse the repository at this point in the history
v2.4.2 GitHub Actions fix
  • Loading branch information
mark-szabo authored Jan 7, 2025
2 parents 23c1ae3 + 3804099 commit f849e90
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 44 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/mimosonk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ env:
jobs:
build:
runs-on: windows-latest
outputs:
build_number: ${{ steps.build_number.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET SDK
Expand Down Expand Up @@ -73,7 +75,7 @@ jobs:
--auth-mode login
--endpoint ${{ env.AZURE_APPCONFIG_ENDPOINT }}
--key VERSION
--value ${{ steps.build_number.outputs.VERSION }}
--value ${{ needs.build.outputs.build_number }}
--yes
- name: Purge Azure CDN endpoint
run: |
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

bin
obj
output
AppPackages
project.lock.json
.vs
Expand All @@ -23,6 +24,9 @@ CarWash\.PWA\.Windows/_pkginfo\.txt

TestResults/
CarWash.PWA/Properties/serviceDependencies.mimosonk.json
CarWash.Functions/Properties/serviceDependencies.func-carwash-mimosonk-prod - Zip Deploy.json
CarWash.Functions/Properties/ServiceDependencies/func-carwash-mimosonk-prod - Zip Deploy/appInsights1.arm.json
CarWash.Functions/Properties/ServiceDependencies/func-carwash-mimosonk-prod - Zip Deploy/storage1.arm.json

# Azure Functions artifacts
bin
Expand All @@ -34,3 +38,4 @@ local.settings.json
__blobstorage__
__queuestorage__
__azurite_db*__.json

1 change: 1 addition & 0 deletions CarWash.Functions/CarWash.Functions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Azure.Identity" Version="1.13.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
Expand Down
87 changes: 46 additions & 41 deletions CarWash.Functions/ParkIntegrationFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace CarWash.Functions
{
public class ParkIntegrationFunction(ILogger<ParkIntegrationFunction> log)
{
private static readonly HttpClient _client = new HttpClient();
private static readonly FunctionsDbContext _context = new FunctionsDbContext();
private static readonly string _parkApiEmail = Environment.GetEnvironmentVariable("ParkApi:Email", EnvironmentVariableTarget.Process);
private static readonly string _parkApiPassword = Environment.GetEnvironmentVariable("ParkApi:Password", EnvironmentVariableTarget.Process);
private static readonly HttpClient _client = new();
private static readonly FunctionsDbContext _context = new();
private static readonly string _parkApiEmail = Environment.GetEnvironmentVariable("ParkApi:Email", EnvironmentVariableTarget.Process) ?? throw new ArgumentNullException("Missing environment variable 'ParkApi:Email'.");
private static readonly string _parkApiPassword = Environment.GetEnvironmentVariable("ParkApi:Password", EnvironmentVariableTarget.Process) ?? throw new ArgumentNullException("Missing environment variable 'ParkApi:Password'.");

/// <summary>
/// Service Bus queue name for the chat bot's vehicle-arrived notification.
Expand All @@ -46,7 +46,7 @@ public async Task RunAsync([TimerTrigger("0 * 6-15 * * 1-5")] TimerInfo timer)

var licensePlates = parkingSessions
.Where(s => s.start > DateTime.UtcNow.AddMinutes(-5))
.Select(s => s.vehicle.normalized_licence_plate.ToUpper())
.Select(s => s.vehicle?.normalized_licence_plate?.ToUpper())
.ToList();

log.LogMetric("VehicleArrived", parkingSessions.Count(s => s.start > DateTime.UtcNow.AddMinutes(-1)));
Expand Down Expand Up @@ -91,9 +91,9 @@ public async Task RunAsync([TimerTrigger("0 * 6-15 * * 1-5")] TimerInfo timer)
Subject = "Welcome in the office! Don't forget to drop off your key!",
Body = $@"Welcome {reservation.User.FirstName},
I just noticed that you've arrived! 👀
Don't forget to leave the key at the reception and <a href='https://carwashu.azurewebsites.net'>confirm drop-off & vehicle location by clicking here</a>!
Don't forget to leave the key at the reception and <a href='https://www.mimosonk.hu/#dropoffkey'>confirm drop-off & vehicle location by clicking here</a>!
If don't want to get email reminders in the future, you can <a href='https://carwashu.azurewebsites.net/settings'>disable it in the settings</a>."
If don't want to get email reminders in the future, you can <a href='https://www.mimosonk.hu/settings'>disable it in the settings</a>."
};

switch (reservation.User.NotificationChannel)
Expand Down Expand Up @@ -204,7 +204,12 @@ private static async Task<List<ParkingSession>> GetParkingSessions(int retryCoun

response.EnsureSuccessStatusCode();

return JsonConvert.DeserializeObject<List<ParkingSession>>(responseContent);
if (responseContent == null) throw new Exception("Response content is null.");

var parkingSessions = JsonConvert.DeserializeObject<List<ParkingSession>>(responseContent);
if (parkingSessions == null) throw new Exception("Deserialized parking sessions are null.");

return parkingSessions;
}
catch (Exception e)
{
Expand All @@ -214,56 +219,56 @@ private static async Task<List<ParkingSession>> GetParkingSessions(int retryCoun

private class ParkingSession
{
public string url { get; set; }
public string uuid { get; set; }
public Vehicle vehicle { get; set; }
public Payment payment { get; set; }
public float price { get; set; }
public object with_pass { get; set; }
public string start_image_color { get; set; }
public string start_image_infra { get; set; }
public bool is_free { get; set; }
public bool is_voided { get; set; }
public DateTime start { get; set; }
public string tenant { get; set; }
public Segment[] segments { get; set; }
public bool is_vehicle_editable { get; set; }
public bool is_started_offline { get; set; }
public string session_type { get; set; }
public string? url { get; set; }
public string? uuid { get; set; }
public Vehicle? vehicle { get; set; }
public Payment? payment { get; set; }
public float? price { get; set; }
public object? with_pass { get; set; }
public string? start_image_color { get; set; }
public string? start_image_infra { get; set; }
public bool? is_free { get; set; }
public bool? is_voided { get; set; }
public DateTime? start { get; set; }
public string? tenant { get; set; }
public Segment[]? segments { get; set; }
public bool? is_vehicle_editable { get; set; }
public bool? is_started_offline { get; set; }
public string? session_type { get; set; }
}

private class Vehicle
{
public string url { get; set; }
public string licence_plate { get; set; }
public string normalized_licence_plate { get; set; }
public string? url { get; set; }
public string? licence_plate { get; set; }
public string? normalized_licence_plate { get; set; }
}

private class Payment
{
public float amount { get; set; }
public string currency { get; set; }
public object invoice_type { get; set; }
public float? amount { get; set; }
public string? currency { get; set; }
public object? invoice_type { get; set; }
}

private class Segment
{
public Zone zone { get; set; }
public string pass_contract { get; set; }
public float price { get; set; }
public DateTime start { get; set; }
public Zone? zone { get; set; }
public string? pass_contract { get; set; }
public float? price { get; set; }
public DateTime? start { get; set; }
public DateTime? end { get; set; }
public string start_image_color { get; set; }
public string start_image_infra { get; set; }
public string end_image_color { get; set; }
public string end_image_infra { get; set; }
public string? start_image_color { get; set; }
public string? start_image_infra { get; set; }
public string? end_image_color { get; set; }
public string? end_image_infra { get; set; }
}

private class Zone
{
public string url { get; set; }
public string name { get; set; }
public string color_code { get; set; }
public string? url { get; set; }
public string? name { get; set; }
public string? color_code { get; set; }
}
}
}
13 changes: 13 additions & 0 deletions CarWash.Functions/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"dependencies": {
"storage1": {
"type": "storage",
"connectionId": "AzureWebJobsStorage"
},
"appInsights1": {
"type": "appInsights",
"connectionId": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"dynamicId": null
}
}
}
2 changes: 1 addition & 1 deletion CarWash.PWA/ClientApp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "carwash_pwa",
"version": "2.4.1",
"version": "2.4.2",
"private": true,
"description": "This app is intended to help employees working in Graphisoft park (Budapest, Hungary) reserve car washing services.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion CarWash.PWA/ClientApp/public/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ workbox.core.setCacheNameDetails({
// Don't forget to increase the revision number of index.html (aka. '/')
// as it is needed to include the newly genereted js and css files.
// Error would be thrown: Refused to execute script from '...' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
const VERSION = '2.4.1';
const VERSION = '2.4.2';
console.log(`Build: ${VERSION}`);
workbox.precaching.cleanupOutdatedCaches();
workbox.precaching.precacheAndRoute([
Expand Down

0 comments on commit f849e90

Please sign in to comment.