From c0f44448759e442098883bbe73c8fb234cf8281b Mon Sep 17 00:00:00 2001 From: Andreas Frisch Date: Wed, 5 Aug 2026 15:36:48 +0200 Subject: [PATCH 1/3] news contains FrontPageSummary --- ...20260805100000_add-frontpage-summary-to-news-item.sql | 5 +++++ src/SelfService/Domain/Models/NewsItem.cs | 9 +++++++-- src/SelfService/Domain/Services/NewsItemService.cs | 2 +- src/SelfService/Infrastructure/Api/ApiResourceFactory.cs | 1 + .../Infrastructure/Api/News/NewsController.cs | 3 ++- .../Infrastructure/Api/News/NewsItemApiResource.cs | 3 +++ .../Infrastructure/Api/News/NewsItemCreateRequest.cs | 2 ++ .../Infrastructure/Api/News/NewsItemUpdateRequest.cs | 1 + .../Infrastructure/Persistence/SelfServiceDbContext.cs | 1 + 9 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 db/migrations/20260805100000_add-frontpage-summary-to-news-item.sql diff --git a/db/migrations/20260805100000_add-frontpage-summary-to-news-item.sql b/db/migrations/20260805100000_add-frontpage-summary-to-news-item.sql new file mode 100644 index 00000000..b83791b2 --- /dev/null +++ b/db/migrations/20260805100000_add-frontpage-summary-to-news-item.sql @@ -0,0 +1,5 @@ +-- Add optional frontpage summary to news items. +-- When populated, this text is shown on the frontpage instead of the full body when the item is highlighted. + +ALTER TABLE "NewsItem" + ADD COLUMN "FrontpageSummary" TEXT; diff --git a/src/SelfService/Domain/Models/NewsItem.cs b/src/SelfService/Domain/Models/NewsItem.cs index b7f04138..4db1219a 100644 --- a/src/SelfService/Domain/Models/NewsItem.cs +++ b/src/SelfService/Domain/Models/NewsItem.cs @@ -4,6 +4,7 @@ public class NewsItem : Entity { public string Title { get; private set; } public string Body { get; private set; } + public string? FrontpageSummary { get; private set; } public DateTime DueDate { get; private set; } public bool IsHighlighted { get; private set; } public string CreatedBy { get; private set; } @@ -17,19 +18,21 @@ public NewsItem( DateTime dueDate, bool isHighlighted, string createdBy, - DateTime createdAt + DateTime createdAt, + string? frontpageSummary = null ) : base(id) { Title = title; Body = body; + FrontpageSummary = frontpageSummary; DueDate = dueDate; IsHighlighted = isHighlighted; CreatedBy = createdBy; CreatedAt = createdAt; } - public void Update(string? title, string? body, DateTime? dueDate, DateTime modifiedAt) + public void Update(string? title, string? body, DateTime? dueDate, DateTime modifiedAt, string? frontpageSummary = null) { if (!string.IsNullOrWhiteSpace(title)) { @@ -46,6 +49,8 @@ public void Update(string? title, string? body, DateTime? dueDate, DateTime modi DueDate = dueDate.Value; } + FrontpageSummary = frontpageSummary; + ModifiedAt = modifiedAt; } diff --git a/src/SelfService/Domain/Services/NewsItemService.cs b/src/SelfService/Domain/Services/NewsItemService.cs index a228b562..4b4f8814 100644 --- a/src/SelfService/Domain/Services/NewsItemService.cs +++ b/src/SelfService/Domain/Services/NewsItemService.cs @@ -39,7 +39,7 @@ public async Task UpdateNewsItem(NewsItemId id, NewsItemUpdateRequest updateRequ await _newsItemRepository.FindById(id) ?? throw new KeyNotFoundException($"News item with id '{id}' not found."); - newsItem.Update(updateRequest.Title, updateRequest.Body, updateRequest.DueDate, DateTime.UtcNow); + newsItem.Update(updateRequest.Title, updateRequest.Body, updateRequest.DueDate, DateTime.UtcNow, updateRequest.FrontpageSummary); } [TransactionalBoundary] diff --git a/src/SelfService/Infrastructure/Api/ApiResourceFactory.cs b/src/SelfService/Infrastructure/Api/ApiResourceFactory.cs index 93322fdf..1ec25ab6 100644 --- a/src/SelfService/Infrastructure/Api/ApiResourceFactory.cs +++ b/src/SelfService/Infrastructure/Api/ApiResourceFactory.cs @@ -2140,6 +2140,7 @@ public NewsItemApiResource Convert(NewsItem newsItem) id: newsItem.Id, title: newsItem.Title, body: newsItem.Body, + frontpageSummary: newsItem.FrontpageSummary, dueDate: newsItem.DueDate, isHighlighted: newsItem.IsHighlighted, isRelevant: newsItem.IsRelevant(), diff --git a/src/SelfService/Infrastructure/Api/News/NewsController.cs b/src/SelfService/Infrastructure/Api/News/NewsController.cs index 0cabe04b..9f47c62e 100644 --- a/src/SelfService/Infrastructure/Api/News/NewsController.cs +++ b/src/SelfService/Infrastructure/Api/News/NewsController.cs @@ -130,7 +130,8 @@ public async Task CreateNewsItem([FromBody] NewsItemCreateRequest dueDate: request.DueDate, isHighlighted: false, createdBy: userId, - createdAt: DateTime.UtcNow + createdAt: DateTime.UtcNow, + frontpageSummary: request.FrontpageSummary ); var created = await _newsItemService.CreateNewsItem(newsItem); diff --git a/src/SelfService/Infrastructure/Api/News/NewsItemApiResource.cs b/src/SelfService/Infrastructure/Api/News/NewsItemApiResource.cs index 6160191d..a5ac024d 100644 --- a/src/SelfService/Infrastructure/Api/News/NewsItemApiResource.cs +++ b/src/SelfService/Infrastructure/Api/News/NewsItemApiResource.cs @@ -9,6 +9,7 @@ public class NewsItemApiResource public NewsItemId Id { get; private set; } public string Title { get; private set; } public string Body { get; private set; } + public string? FrontpageSummary { get; private set; } public DateTime DueDate { get; private set; } public bool IsHighlighted { get; private set; } public bool IsRelevant { get; private set; } @@ -33,6 +34,7 @@ public NewsItemApiResource( NewsItemId id, string title, string body, + string? frontpageSummary, DateTime dueDate, bool isHighlighted, bool isRelevant, @@ -45,6 +47,7 @@ NewsItemLinks links Id = id; Title = title; Body = body; + FrontpageSummary = frontpageSummary; DueDate = dueDate; IsHighlighted = isHighlighted; IsRelevant = isRelevant; diff --git a/src/SelfService/Infrastructure/Api/News/NewsItemCreateRequest.cs b/src/SelfService/Infrastructure/Api/News/NewsItemCreateRequest.cs index 579ba3f2..4919f244 100644 --- a/src/SelfService/Infrastructure/Api/News/NewsItemCreateRequest.cs +++ b/src/SelfService/Infrastructure/Api/News/NewsItemCreateRequest.cs @@ -10,6 +10,8 @@ public class NewsItemCreateRequest [Required] public string? Body { get; set; } + public string? FrontpageSummary { get; set; } + [Required] public DateTime DueDate { get; set; } } diff --git a/src/SelfService/Infrastructure/Api/News/NewsItemUpdateRequest.cs b/src/SelfService/Infrastructure/Api/News/NewsItemUpdateRequest.cs index 3cd98687..13b165b6 100644 --- a/src/SelfService/Infrastructure/Api/News/NewsItemUpdateRequest.cs +++ b/src/SelfService/Infrastructure/Api/News/NewsItemUpdateRequest.cs @@ -4,5 +4,6 @@ public class NewsItemUpdateRequest { public string? Title { get; set; } public string? Body { get; set; } + public string? FrontpageSummary { get; set; } public DateTime? DueDate { get; set; } } diff --git a/src/SelfService/Infrastructure/Persistence/SelfServiceDbContext.cs b/src/SelfService/Infrastructure/Persistence/SelfServiceDbContext.cs index cf550cc5..e0eaeb6a 100644 --- a/src/SelfService/Infrastructure/Persistence/SelfServiceDbContext.cs +++ b/src/SelfService/Infrastructure/Persistence/SelfServiceDbContext.cs @@ -654,6 +654,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) cfg.Property(x => x.Id).ValueGeneratedNever(); cfg.Property(x => x.Title); cfg.Property(x => x.Body); + cfg.Property(x => x.FrontpageSummary); cfg.Property(x => x.DueDate); cfg.Property(x => x.IsHighlighted); cfg.Property(x => x.CreatedBy); From e8dff8d7b4847fd11154ae30b4048e13b59bcd29 Mon Sep 17 00:00:00 2001 From: Andreas Frisch Date: Wed, 5 Aug 2026 16:19:20 +0200 Subject: [PATCH 2/3] seed data update --- db/seed/NewsItem.csv | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/seed/NewsItem.csv b/db/seed/NewsItem.csv index 895c0068..cdb27974 100644 --- a/db/seed/NewsItem.csv +++ b/db/seed/NewsItem.csv @@ -1,4 +1,4 @@ -Id;Title;Body;DueDate;IsHighlighted;CreatedBy;CreatedAt;ModifiedAt -A1000000-0000-0000-0000-000000000001;Welcome to the new Self Service Portal;We have launched a completely redesigned Self Service Portal with improved navigation, faster load times, and a new dark mode. Check it out and let us know what you think in the #cloud-engineering Slack channel.;2026-06-30T23:59:59;true;seedscript;2026-04-22T08:00:00; -A1000000-0000-0000-0000-000000000002;Kubernetes 1.32 upgrade scheduled for May;We will be upgrading all clusters to Kubernetes 1.32 on May 12th. There will be a brief rolling restart of workloads. No action is required from capability teams, but please review the changelog for any deprecations that may affect you.;2026-05-12T23:59:59;false;seedscript;2026-04-15T09:00:00; -A1000000-0000-0000-0000-000000000003;New ECR lifecycle policies in effect;Automatic cleanup policies have been applied to all ECR repositories. Images older than 90 days that are not tagged as 'latest' or with a semantic version will be pruned. Reach out to Cloud Engineering if you have questions.;2026-05-31T23:59:59;false;seedscript;2026-04-10T11:00:00; +Id;Title;Body;DueDate;IsHighlighted;CreatedBy;CreatedAt;ModifiedAt;FrontpageSummary +A1000000-0000-0000-0000-000000000001;Welcome to the new Self Service Portal;We have launched a completely redesigned Self Service Portal with improved navigation, faster load times, and a new dark mode. Check it out and let us know what you think in the #cloud-engineering Slack channel.;2026-06-30T23:59:59;true;seedscript;2026-04-22T08:00:00;; +A1000000-0000-0000-0000-000000000002;Kubernetes 1.32 upgrade scheduled for May;We will be upgrading all clusters to Kubernetes 1.32 on May 12th. There will be a brief rolling restart of workloads. No action is required from capability teams, but please review the changelog for any deprecations that may affect you.;2026-05-12T23:59:59;false;seedscript;2026-04-15T09:00:00;; +A1000000-0000-0000-0000-000000000003;New ECR lifecycle policies in effect;Automatic cleanup policies have been applied to all ECR repositories. Images older than 90 days that are not tagged as 'latest' or with a semantic version will be pruned. Reach out to Cloud Engineering if you have questions.;2026-05-31T23:59:59;false;seedscript;2026-04-10T11:00:00;; From 622fae860b3564df223bf670023ab72703ca9a74 Mon Sep 17 00:00:00 2001 From: Andreas Frisch Date: Thu, 6 Aug 2026 10:43:52 +0200 Subject: [PATCH 3/3] format --- src/SelfService/Domain/Models/NewsItem.cs | 8 +++++++- src/SelfService/Domain/Services/NewsItemService.cs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/SelfService/Domain/Models/NewsItem.cs b/src/SelfService/Domain/Models/NewsItem.cs index 4db1219a..2dd13c1a 100644 --- a/src/SelfService/Domain/Models/NewsItem.cs +++ b/src/SelfService/Domain/Models/NewsItem.cs @@ -32,7 +32,13 @@ public NewsItem( CreatedAt = createdAt; } - public void Update(string? title, string? body, DateTime? dueDate, DateTime modifiedAt, string? frontpageSummary = null) + public void Update( + string? title, + string? body, + DateTime? dueDate, + DateTime modifiedAt, + string? frontpageSummary = null + ) { if (!string.IsNullOrWhiteSpace(title)) { diff --git a/src/SelfService/Domain/Services/NewsItemService.cs b/src/SelfService/Domain/Services/NewsItemService.cs index 4b4f8814..f04f3dd9 100644 --- a/src/SelfService/Domain/Services/NewsItemService.cs +++ b/src/SelfService/Domain/Services/NewsItemService.cs @@ -39,7 +39,13 @@ public async Task UpdateNewsItem(NewsItemId id, NewsItemUpdateRequest updateRequ await _newsItemRepository.FindById(id) ?? throw new KeyNotFoundException($"News item with id '{id}' not found."); - newsItem.Update(updateRequest.Title, updateRequest.Body, updateRequest.DueDate, DateTime.UtcNow, updateRequest.FrontpageSummary); + newsItem.Update( + updateRequest.Title, + updateRequest.Body, + updateRequest.DueDate, + DateTime.UtcNow, + updateRequest.FrontpageSummary + ); } [TransactionalBoundary]