From dd9ed233614ab311934e796cdc466dd42e8b64ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Arod?= Date: Wed, 6 May 2026 13:01:09 +0200 Subject: [PATCH] feat: display both first and latest postsnapshot date in case of multiple snapshots Fixes #281 --- .../entrypoints/posts/Posts/PostDetailPage.tsx | 11 ++++++++--- .../posts/Shared/PostSummary.stories.tsx | 2 ++ browser-extension/src/shared/model/post/Post.ts | 9 +++++++++ .../shared/model/post/buildPostFromSnapshots.ts | 2 ++ .../src/shared/utils/__tests__/post-util.test.ts | 15 ++++----------- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/browser-extension/src/entrypoints/posts/Posts/PostDetailPage.tsx b/browser-extension/src/entrypoints/posts/Posts/PostDetailPage.tsx index c6371d7..3abe7e0 100644 --- a/browser-extension/src/entrypoints/posts/Posts/PostDetailPage.tsx +++ b/browser-extension/src/entrypoints/posts/Posts/PostDetailPage.tsx @@ -76,10 +76,15 @@ function PostDetailPage() {

Analyse des commentaires malveillants

- +
Données collectées le{" "} - {formatAnalysisDate(post.latestAnalysisDate)} - + {formatAnalysisDate(post.firstAnalysisDate)} +
+ {post.analysisCount > 1 && ( +
+ Mise à jour le {formatAnalysisDate(post.latestAnalysisDate)} +
+ )}

Publication analysée

diff --git a/browser-extension/src/entrypoints/posts/Shared/PostSummary.stories.tsx b/browser-extension/src/entrypoints/posts/Shared/PostSummary.stories.tsx index d005f49..7bc15a3 100644 --- a/browser-extension/src/entrypoints/posts/Shared/PostSummary.stories.tsx +++ b/browser-extension/src/entrypoints/posts/Shared/PostSummary.stories.tsx @@ -38,6 +38,8 @@ const inProgressPost: Post = { comments: Array(100).fill(exampleComment), latestAnalysisDate: "2026-03-22T00:00:00.000Z", latestAnalysisStatus: "IN_PROGRESS", + firstAnalysisDate: "2026-03-22T00:00:00.000Z", + analysisCount: 1, }; const completedPost: Post = { diff --git a/browser-extension/src/shared/model/post/Post.ts b/browser-extension/src/shared/model/post/Post.ts index 1cc359d..3283706 100644 --- a/browser-extension/src/shared/model/post/Post.ts +++ b/browser-extension/src/shared/model/post/Post.ts @@ -12,6 +12,15 @@ export type Post = PostSharedProperties & { */ comments: PostComment[]; + /** + * Date of first PostSnapshot + */ + firstAnalysisDate: string; + + /** + * Number of PostSnapshot associated to this post + */ + analysisCount: number; /** * Date of the latest snapshot on which this post is based. */ diff --git a/browser-extension/src/shared/model/post/buildPostFromSnapshots.ts b/browser-extension/src/shared/model/post/buildPostFromSnapshots.ts index fc2f7d7..3bf9c5c 100644 --- a/browser-extension/src/shared/model/post/buildPostFromSnapshots.ts +++ b/browser-extension/src/shared/model/post/buildPostFromSnapshots.ts @@ -30,6 +30,8 @@ export function buildPostFromSnapshots(snapshots: PostSnapshot[]): Post { textContent: latest.textContent, title: latest.title, comments: buildCommentsFromSnapshots(oldestFirst), + firstAnalysisDate: oldest.scrapedAt, + analysisCount: snapshots.length, latestAnalysisDate: latest.scrapedAt, latestAnalysisStatus: latest.classificationStatus, }; diff --git a/browser-extension/src/shared/utils/__tests__/post-util.test.ts b/browser-extension/src/shared/utils/__tests__/post-util.test.ts index 532ab56..f5b1c1b 100644 --- a/browser-extension/src/shared/utils/__tests__/post-util.test.ts +++ b/browser-extension/src/shared/utils/__tests__/post-util.test.ts @@ -16,18 +16,9 @@ import { Post, PostComment } from "@/shared/model/post/Post"; * @returns Array containing a single Post with dummy data */ function createDummyPostWithDate(publishedAt: PublicationDate): Post { - return { - postId: "dummy-post-1", - socialNetwork: SocialNetwork.YouTube, - url: "https://www.youtube.com/watch?v=dummy", + return createDummyPost({ publishedAt, - author: { - name: "Dummy Author", - accountHref: "https://youtube.com/@dummyauthor", - }, - latestAnalysisDate: new Date().toLocaleDateString(), - comments: [], - }; + }); } /** @@ -48,6 +39,8 @@ function createDummyPost(overrides: Partial = {}): Post { name: "Dummy Author", accountHref: "https://youtube.com/@dummyauthor", }, + firstAnalysisDate: new Date().toLocaleDateString(), + analysisCount: 1, latestAnalysisDate: new Date().toLocaleDateString(), comments: [], ...overrides,