Skip to content

Commit fa7aa55

Browse files
authored
Add dates to delivery preview logs (#435)
1 parent 8b8545c commit fa7aa55

11 files changed

Lines changed: 862 additions & 325 deletions

File tree

services/backend-api/client/src/features/feed/api/getDeliveryPreview.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ function transformResponse(
175175
articleId: article.articleId,
176176
articleIdHash: article.articleIdHash,
177177
articleTitle: article.articleTitle,
178+
articlePublishedDate: article.articlePublishedDate,
179+
articleStoredDate: article.articleStoredDate,
178180
outcome: article.outcome,
179181
outcomeReason: article.outcomeReason,
180182
mediumResults: article.mediumResults.map((medium): MediumDeliveryResult => {

services/backend-api/client/src/features/feed/components/UserFeedLogs/DeliveryPreview/ArticleDeliveryDetails.tsx

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
Badge,
33
Box,
44
Button,
5+
Grid,
56
Stack,
67
Table,
78
TableContainer,
@@ -10,11 +11,13 @@ import {
1011
Text,
1112
Th,
1213
Thead,
14+
Tooltip,
1315
Tr,
1416
useDisclosure,
1517
} from "@chakra-ui/react";
1618
import { Link } from "react-router-dom";
1719
import { ExternalLinkIcon } from "@chakra-ui/icons";
20+
import dayjs from "dayjs";
1821
import {
1922
ArticleDeliveryOutcome,
2023
ArticleDeliveryResult,
@@ -191,6 +194,94 @@ export const ArticleDeliveryDetails = ({ result, lastRequestAtUnix }: Props) =>
191194
{getDisplayText()}
192195
</Text>
193196
</Box>
197+
<Box>
198+
<Text fontWeight="semibold" mb={2}>
199+
Dates
200+
</Text>
201+
<Grid as="dl" templateColumns="140px 1fr" gap={1} fontSize="sm" m={0}>
202+
<Text as="dt" color="gray.400">
203+
Published
204+
</Text>
205+
<Box as="dd" ml={0}>
206+
{result.articlePublishedDate ? (
207+
<Tooltip
208+
label={dayjs(result.articlePublishedDate).format("DD MMM YYYY, HH:mm:ss")}
209+
hasArrow
210+
>
211+
<Text
212+
as="time"
213+
dateTime={result.articlePublishedDate}
214+
tabIndex={0}
215+
cursor="default"
216+
color="gray.300"
217+
display="inline"
218+
borderBottom="1px dashed"
219+
borderColor="whiteAlpha.300"
220+
sx={{ cursor: "help" }}
221+
>
222+
{dayjs(result.articlePublishedDate).fromNow()}
223+
</Text>
224+
</Tooltip>
225+
) : (
226+
<Tooltip
227+
label="This feed does not include a published date for this article"
228+
hasArrow
229+
>
230+
<Text
231+
tabIndex={0}
232+
color="gray.400"
233+
display="inline"
234+
borderBottom="1px dashed"
235+
borderColor="whiteAlpha.200"
236+
sx={{ cursor: "help" }}
237+
aria-label="Not available. This feed does not include a published date for this article."
238+
>
239+
--
240+
</Text>
241+
</Tooltip>
242+
)}
243+
</Box>
244+
<Text as="dt" color="gray.400">
245+
First detected
246+
</Text>
247+
<Box as="dd" ml={0}>
248+
{result.articleStoredDate ? (
249+
<Tooltip
250+
label={dayjs(result.articleStoredDate).format("DD MMM YYYY, HH:mm:ss")}
251+
hasArrow
252+
>
253+
<Text
254+
as="time"
255+
dateTime={result.articleStoredDate}
256+
tabIndex={0}
257+
cursor="default"
258+
color="gray.300"
259+
display="inline"
260+
borderBottom="1px dashed"
261+
borderColor="whiteAlpha.300"
262+
sx={{ cursor: "help" }}
263+
>
264+
{dayjs(result.articleStoredDate).fromNow()}
265+
</Text>
266+
</Tooltip>
267+
) : (
268+
<Tooltip label="This article has not been stored yet" hasArrow>
269+
<Text
270+
tabIndex={0}
271+
color="gray.400"
272+
display="inline"
273+
borderBottom="1px dashed"
274+
borderColor="whiteAlpha.200"
275+
sx={{ cursor: "help" }}
276+
aria-label="Not available. This article has not been stored yet."
277+
>
278+
--
279+
</Text>
280+
</Tooltip>
281+
)}
282+
</Box>
283+
</Grid>
284+
</Box>
194285
{!isLearningPhase && result.mediumResults.length > 0 && (
195286
<Box>
196287
<Text fontWeight="semibold" mb={2}>

services/backend-api/client/src/features/feed/types/DeliveryPreview.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ export const BackendArticleDeliveryResultSchema = object({
124124
articleId: string().required(),
125125
articleIdHash: string().required(),
126126
articleTitle: string().nullable(),
127+
articlePublishedDate: string().nullable(),
128+
articleStoredDate: string().nullable(),
127129
outcome: string().oneOf(Object.values(ArticleDeliveryOutcome)).required() as any,
128130
outcomeReason: string().required(),
129131
mediumResults: array(BackendMediumDeliveryResultSchema.required()).required(),
@@ -140,6 +142,8 @@ export const ArticleDeliveryResultSchema = object({
140142
articleId: string().required(),
141143
articleIdHash: string().required(),
142144
articleTitle: string().nullable(),
145+
articlePublishedDate: string().nullable(),
146+
articleStoredDate: string().nullable(),
143147
outcome: string().oneOf(Object.values(ArticleDeliveryOutcome)).required() as any,
144148
outcomeReason: string().required(),
145149
mediumResults: array(MediumDeliveryResultSchema.required()).required(),

services/feed-requests/src/app.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ export class AppModule implements OnApplicationShutdown {
2727
}
2828

2929
const prefetchCount = configVals.FEED_REQUESTS_RABBITMQ_PREFETCH_COUNT;
30-
const poolMax =
31-
configVals.FEED_REQUESTS_POSTGRES_POOL_MAX ?? prefetchCount * 3;
30+
const poolMax = prefetchCount * 3;
3231

3332
logger.info(`${replicaUris.length} read replicas discovered`);
3433

0 commit comments

Comments
 (0)