From 55717cdf1270e4a65ed56a7e509fd7503f2d0075 Mon Sep 17 00:00:00 2001 From: eebbesen Date: Thu, 2 Jan 2025 17:03:55 -0600 Subject: [PATCH 1/3] Revert "telemetry logging (#60)" This reverts commit 6d581543e756a1b8eea000b635f161d1c618d6cc. --- StpFoodBlazor/StpFoodBlazor/Program.cs | 3 --- StpFoodBlazor/StpFoodBlazor/StpFoodBlazor.csproj | 1 - 2 files changed, 4 deletions(-) diff --git a/StpFoodBlazor/StpFoodBlazor/Program.cs b/StpFoodBlazor/StpFoodBlazor/Program.cs index aa90a84..39d7ae5 100644 --- a/StpFoodBlazor/StpFoodBlazor/Program.cs +++ b/StpFoodBlazor/StpFoodBlazor/Program.cs @@ -1,6 +1,5 @@ using StpFoodBlazor.Components; using StpFoodBlazor.Services; -using Azure.Monitor.OpenTelemetry.AspNetCore; var builder = WebApplication.CreateBuilder(args); builder.Configuration.AddEnvironmentVariables(); @@ -9,8 +8,6 @@ builder.Services.AddRazorComponents() .AddInteractiveServerComponents() .AddInteractiveWebAssemblyComponents(); -builder.Services.AddOpenTelemetry().UseAzureMonitor(); - builder.Services.AddHttpClient(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/StpFoodBlazor/StpFoodBlazor/StpFoodBlazor.csproj b/StpFoodBlazor/StpFoodBlazor/StpFoodBlazor.csproj index df1bc93..e157cda 100644 --- a/StpFoodBlazor/StpFoodBlazor/StpFoodBlazor.csproj +++ b/StpFoodBlazor/StpFoodBlazor/StpFoodBlazor.csproj @@ -8,7 +8,6 @@ - From 778b06b6f106453399469d79e8c58ee7eac0231f Mon Sep 17 00:00:00 2001 From: eebbesen Date: Fri, 3 Jan 2025 16:54:14 -0600 Subject: [PATCH 2/3] adding end date filter on gift cards --- .../StpFoodBlazor/Helpers/GiftCardFilter.cs | 8 +-- .../Helpers/GiftCardFilterTest.cs | 38 ++++++++++-- .../Pages/GiftCardsTest.razor | 13 ++-- .../StpFoodBlazorTest/fixtures/giftcards.json | 60 +++++++++---------- 4 files changed, 74 insertions(+), 45 deletions(-) diff --git a/StpFoodBlazor/StpFoodBlazor/Helpers/GiftCardFilter.cs b/StpFoodBlazor/StpFoodBlazor/Helpers/GiftCardFilter.cs index 5bf0e21..3b0da60 100644 --- a/StpFoodBlazor/StpFoodBlazor/Helpers/GiftCardFilter.cs +++ b/StpFoodBlazor/StpFoodBlazor/Helpers/GiftCardFilter.cs @@ -16,17 +16,17 @@ public GiftCard[] Filter() { if (GiftCards == null) { return []; } - return FilterByExpiryDate(GiftCards); + return FilterByDates(GiftCards); } private static DateTime convertStringToDate(string date) { return DateTime.Parse(date, CultureInfo.InvariantCulture); } - private GiftCard[] FilterByExpiryDate(GiftCard[] giftcards) { + private GiftCard[] FilterByDates(GiftCard[] giftcards) { return giftcards.Where(giftcard => - string.IsNullOrWhiteSpace(giftcard.End) || - convertStringToDate(giftcard.End).Date > _timeService.GetCurrentDate().Date + (string.IsNullOrWhiteSpace(giftcard.Start) || convertStringToDate(giftcard.Start).Date <= _timeService.GetCurrentDate().Date) && + (string.IsNullOrWhiteSpace(giftcard.End) || convertStringToDate(giftcard.End).Date >= _timeService.GetCurrentDate().Date) ).ToArray(); } } diff --git a/StpFoodBlazor/StpFoodBlazorTest/Helpers/GiftCardFilterTest.cs b/StpFoodBlazor/StpFoodBlazorTest/Helpers/GiftCardFilterTest.cs index 03ed41f..b528973 100644 --- a/StpFoodBlazor/StpFoodBlazorTest/Helpers/GiftCardFilterTest.cs +++ b/StpFoodBlazor/StpFoodBlazorTest/Helpers/GiftCardFilterTest.cs @@ -26,8 +26,10 @@ public void Filter_FiltersCorrectly() GiftCardFixtures.kincaids }; - GiftCardFilter GiftCardFilter = new(timeService); - GiftCardFilter.GiftCards = GiftCardFixtures.allGiftCards;; + GiftCardFilter GiftCardFilter = new(timeService) + { + GiftCards = GiftCardFixtures.allGiftCards + }; var filteredGiftCards = GiftCardFilter.Filter(); @@ -37,19 +39,45 @@ public void Filter_FiltersCorrectly() } } + [Fact] + public void Filter_FiltersNotStarted() + { + var expected = new GiftCard[]{ + GiftCardFixtures.wildBills, + GiftCardFixtures.wildBills2, + GiftCardFixtures.kincaids + }; + + GiftCardFilter GiftCardFilter = new(timeService) + { + GiftCards = GiftCardFixtures.allGiftCards + }; + + timeService.CurrentDate = new DateTime(2025, 12, 10, 0, 0, 0, DateTimeKind.Utc); + + var filteredGiftCards = GiftCardFilter.Filter(); + + for (int i = 0; i < expected.Length; i++) + { + Assert.Equal(expected[i].Deal, filteredGiftCards[i].Deal); + } + } + [Fact] - public void Filter_FiltersExpired() + public void Filter_FiltersEnded() { var expected = new GiftCard[] { GiftCardFixtures.byLakeElmoInn }; - GiftCardFilter GiftCardFilter = new(timeService); - GiftCardFilter.GiftCards = new GiftCard[] + GiftCardFilter GiftCardFilter = new(timeService) { + GiftCards = + [ GiftCardFixtures.urbanWok, GiftCardFixtures.byLakeElmoInn + ] }; timeService.CurrentDate = new DateTime(2024, 12, 10, 0, 0, 0, DateTimeKind.Utc); diff --git a/StpFoodBlazor/StpFoodBlazorTest/Pages/GiftCardsTest.razor b/StpFoodBlazor/StpFoodBlazorTest/Pages/GiftCardsTest.razor index c6c9916..fddc0c3 100644 --- a/StpFoodBlazor/StpFoodBlazorTest/Pages/GiftCardsTest.razor +++ b/StpFoodBlazor/StpFoodBlazorTest/Pages/GiftCardsTest.razor @@ -41,8 +41,9 @@ } [Fact] - public void GiftCardsShouldRenderRecords() + public void GiftCardsShouldRenderRecords20241210() { + timeService.CurrentDate = new DateTime(2024, 12, 10); var cut = ctx.Render(@); var elements = getElements(cut); @@ -50,7 +51,7 @@ Assert.Equal("Buy $100 get $20", elements.Children[0].Children[1].InnerHtml); Assert.Equal("$20 valid 01/01/2025 - 04/30/2025", elements.Children[0].Children[2].InnerHtml); Assert.Equal("", elements.Children[0].Children[3].InnerHtml); - Assert.Equal("12/24", elements.Children[0].Children[4].InnerHtml); + Assert.Equal("12/24/2024", elements.Children[0].Children[4].InnerHtml); } [Fact] @@ -60,9 +61,9 @@ var cut = ctx.Render(@); var elements = getElements(cut); - Assert.Equal(31, elements.ChildElementCount); + Assert.Equal(30, elements.ChildElementCount); Assert.Equal("1881 by Lake Elmo Inn", elements.Children[0].Children[0].InnerHtml); - Assert.Equal("Wild Bill Sports Saloon", elements.Children[30].Children[0].InnerHtml); + Assert.Equal("Wild Bill Sports Saloon", elements.Children[29].Children[0].InnerHtml); } [Fact] @@ -72,9 +73,9 @@ var cut = ctx.Render(@); var elements = getElements(cut); - Assert.Equal(38, elements.ChildElementCount); + Assert.Equal(37, elements.ChildElementCount); Assert.Equal("1881 by Lake Elmo Inn", elements.Children[0].Children[0].InnerHtml); - Assert.Equal("Wild Bill Sports Saloon", elements.Children[37].Children[0].InnerHtml); + Assert.Equal("Wild Bill Sports Saloon", elements.Children[36].Children[0].InnerHtml); } private IElement getElements(IRenderedFragment cut) diff --git a/StpFoodBlazor/StpFoodBlazorTest/fixtures/giftcards.json b/StpFoodBlazor/StpFoodBlazorTest/fixtures/giftcards.json index 7fb72e7..31ff4a9 100644 --- a/StpFoodBlazor/StpFoodBlazorTest/fixtures/giftcards.json +++ b/StpFoodBlazor/StpFoodBlazorTest/fixtures/giftcards.json @@ -5,7 +5,7 @@ "Deal": "Buy $100 get $10", "Terms": "$10 valid 01/02/2025 - 12/30/2025", "Start Date": "", - "End Date": "12/23", + "End Date": "12/23/2024", "URL": "https://damicogiftcards.com/", "Purchased": null }, @@ -14,8 +14,8 @@ "Name": "The Saint Paul Grill", "Deal": "Buy $100 get $25", "Terms": "* $25 valid 01/01/2025 - 10/31/2025\n* Must purchase cards in person, not online", - "Start Date": "11/01", - "End Date": "12/31", + "Start Date": "11/01/2024", + "End Date": "12/31/2024", "URL": "https://www.stpaulgrill.com/gift-cards/", "Purchased": null }, @@ -25,7 +25,7 @@ "Deal": "Buy $25 get a free 6\"", "Terms": "", "Start Date": "", - "End Date": "12/31", + "End Date": "12/31/2024", "URL": "https://www.subway.com/en-us/subwaycard", "Purchased": null }, @@ -104,8 +104,8 @@ "Name": "Red Rabbit", "Deal": "Buy $100 get $30", "Terms": "$30 valid 01/01/2025 - 05/31/2025\n$30 valid at Red Cow and Red Rabbit", - "Start Date": "11/28", - "End Date": "11/29", + "Start Date": "11/28/2024", + "End Date": "11/29/2024", "URL": "https://redrabbitmn.com/holiday-gift-cards/", "Purchased": "1" }, @@ -124,8 +124,8 @@ "Name": "Qdoba", "Deal": "Buy $50 get $10 ", "Terms": "Digital bonus is redeemable 1/1/25 through 2/28/25", - "Start Date": "11/01", - "End Date": "12/31", + "Start Date": "11/01/2024", + "End Date": "12/31/2024", "URL": "https://www.qdoba.com/gift-cards", "Purchased": null }, @@ -134,8 +134,8 @@ "Name": "Qdoba", "Deal": "Buy $50 get $15", "Terms": "Digital bonus is redeemable 1/1/25 through 2/28/25", - "Start Date": "11/29", - "End Date": "12/2", + "Start Date": "11/29/2024", + "End Date": "12/2/2024", "URL": "https://www.qdoba.com/gift-cards?&utm_medium=email&utm_source=paytronix&utm_campaign=1538_2025_us_email_holiday_gift_card_promotion&utm_content=nov_19", "Purchased": null }, @@ -164,8 +164,8 @@ "Name": "Smash Burger", "Deal": "Buy $25 get $10", "Terms": "$10 valid 11/18/2024 - 01/30/2025", - "Start Date": "11/18", - "End Date": "12/31", + "Start Date": "11/18/2024", + "End Date": "12/31/2024", "URL": "https://smashburger.com/deals?lid=m39ye21fp1dj&utm_source=email&utm_campaign=8058_2024_SB_NA_USA_EMAIL_HOLIDAY_GIFT_CARD&utm_medium=marketing&utm_content=cta", "Purchased": null }, @@ -185,7 +185,7 @@ "Deal": "Buy $50 get $10 ", "Terms": "$10 valid 01/01/2025 - 03/31/2025 at The Freehouse, The Lowry, Longfellow Grill, Edina Grill, 3 Squares, Highland Grill, Groveland Tap", "Start Date": "", - "End Date": "12/31", + "End Date": "12/31/2024", "URL": "https://www.blueplaterestaurantco.com/gift-cards", "Purchased": null }, @@ -195,7 +195,7 @@ "Deal": "Buy $100 get $25 ", "Terms": "$25 valid 01/01/2025 - 03/31/2025 at The Freehouse, The Lowry, Longfellow Grill, Edina Grill, 3 Squares, Highland Grill, Groveland Tap", "Start Date": "", - "End Date": "12/31", + "End Date": "12/31/2024", "URL": "https://www.blueplaterestaurantco.com/gift-cards", "Purchased": null }, @@ -204,8 +204,8 @@ "Name": "Blue Plate Restaurants", "Deal": "Buy $100 get $35 ", "Terms": "$35 valid 01/01/2025 - 03/31/2025 at The Freehouse, The Lowry, Longfellow Grill, Edina Grill, 3 Squares, Highland Grill, Groveland Tap", - "Start Date": "11/29", - "End Date": "12/2", + "Start Date": "11/29/2024", + "End Date": "12/2/2024", "URL": "https://www.blueplaterestaurantco.com/gift-cards", "Purchased": null }, @@ -214,8 +214,8 @@ "Name": "Urban Wok", "Deal": "Buy $25 get $25", "Terms": "Must purchase in $25 increments to get deal. Full $50 goes to recipient.", - "Start Date": "11/22", - "End Date": "12/2", + "Start Date": "11/22/2024", + "End Date": "12/2/2024", "URL": "https://www.urbanwokusa.com/", "Purchased": "4" }, @@ -225,7 +225,7 @@ "Deal": "Buy $40 get $10", "Terms": "$10 valid until 02/28/2025", "Start Date": "", - "End Date": "12/29", + "End Date": "12/29/2024", "URL": "https://www.culvers.com/gift-cards", "Purchased": null }, @@ -234,8 +234,8 @@ "Name": "Fandango", "Deal": "20% off $50 or more with code NOVFLASH24", "Terms": "", - "Start Date": "11/26", - "End Date": "12/02", + "Start Date": "11/26/2024", + "End Date": "12/02/2024", "URL": "https://www.fandango.com/fandango-gift-cards", "Purchased": "1" }, @@ -244,8 +244,8 @@ "Name": "Red Lobster", "Deal": "$90 for $100 gift card and $40 in $10 bonus cards", "Terms": "Bonus cards valid 1/1/25 through 2/28/25, excluding 2/14/25, and require a minimum purchase of $40", - "Start Date": "11/29", - "End Date": "12/02", + "Start Date": "11/29/2024", + "End Date": "12/02/2024", "URL": "https://www.redlobster.com/gift-cards/", "Purchased": null }, @@ -265,7 +265,7 @@ "Deal": "$5 off $25", "Terms": "", "Start Date": "", - "End Date": "12/02", + "End Date": "12/02/2024", "URL": "https://potbelly.myguestaccount.com/en-us/guest/egift?page=cardInfo", "Purchased": "4" }, @@ -275,7 +275,7 @@ "Deal": "15% off gift cards with code NAFNAF15", "Terms": "", "Start Date": "", - "End Date": "12/02", + "End Date": "12/02/2024", "URL": "https://wwws-usa1.givex.com/cws4.0/nafnafgrill/", "Purchased": null }, @@ -285,7 +285,7 @@ "Deal": "Buy $100 get $20", "Terms": "$20 valid 01/01/2025 - 04/30/2025", "Start Date": "", - "End Date": "12/24", + "End Date": "12/24/2024", "URL": "https://1881bylei.com/gift-cards/", "Purchased": null }, @@ -304,8 +304,8 @@ "Name": "Chipotle", "Deal": "Buy $50 get $10 ", "Terms": "$10 expires 01/31/2025", - "Start Date": "12/18", - "End Date": "12/21", + "Start Date": "12/18/2024", + "End Date": "12/21/2024", "URL": "https://www.chipotle.com/holiday-gift-cards", "Purchased": null }, @@ -344,8 +344,8 @@ "Name": "Pajarito", "Deal": "Buy $100 get $30", "Terms": "", - "Start Date": "11/29", - "End Date": "11/29", + "Start Date": "11/29/2024", + "End Date": "11/29/2024", "URL": "https://www.instagram.com/p/DC8E1anq0_V/", "Purchased": "1" }, From 30121a1c92a09f04d53abb3db9de5e80f907f814 Mon Sep 17 00:00:00 2001 From: eebbesen Date: Fri, 3 Jan 2025 16:59:03 -0600 Subject: [PATCH 3/3] deal end date filter --- StpFoodBlazor/StpFoodBlazor/Models/Deal.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/StpFoodBlazor/StpFoodBlazor/Models/Deal.cs b/StpFoodBlazor/StpFoodBlazor/Models/Deal.cs index 9b82b62..3862504 100644 --- a/StpFoodBlazor/StpFoodBlazor/Models/Deal.cs +++ b/StpFoodBlazor/StpFoodBlazor/Models/Deal.cs @@ -12,9 +12,7 @@ public class DealEvent [JsonPropertyName("Happy Hour")] public string? HappyHour { get; set; } - [JsonPropertyName("Start Date")] public string? Start { get; set; } - [JsonPropertyName("End Date")] public string? End { get; set; } } }