Skip to content

Commit 2eb4714

Browse files
committed
update after adding datePublished to Prospect type in graph
- retrieves datePublished from the graph - re-enables display of and filtering by datePublished
1 parent 6484e70 commit 2eb4714

File tree

7 files changed

+21
-69
lines changed

7 files changed

+21
-69
lines changed

src/api/fragments/prospectWithCorpusItems.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const ProspectDataWithCorpusItems = gql`
1515
prospectType
1616
url
1717
createdAt
18+
datePublished
1819
imageUrl
1920
authors
2021
publisher

src/api/generatedTypes.ts

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,7 @@ export type Prospect = {
16111611
approvedCorpusItem?: Maybe<ApprovedCorpusItem>;
16121612
authors?: Maybe<Scalars['String']>;
16131613
createdAt?: Maybe<Scalars['Int']>;
1614+
datePublished?: Maybe<Scalars['String']>;
16141615
domain?: Maybe<Scalars['String']>;
16151616
excerpt?: Maybe<Scalars['String']>;
16161617
id: Scalars['ID'];
@@ -2581,15 +2582,6 @@ export enum Videoness {
25812582
NoVideos = 'NO_VIDEOS',
25822583
}
25832584

2584-
export type BasicParserItemDataFragment = {
2585-
__typename?: 'Item';
2586-
givenUrl: any;
2587-
itemId: string;
2588-
normalUrl: string;
2589-
datePublished?: any | null;
2590-
timeToRead?: number | null;
2591-
};
2592-
25932585
export type CollectionAuthorDataFragment = {
25942586
__typename?: 'CollectionAuthor';
25952587
externalId: string;
@@ -2984,6 +2976,7 @@ export type ProspectDataWithCorpusItemsFragment = {
29842976
prospectType: string;
29852977
url: string;
29862978
createdAt?: number | null;
2979+
datePublished?: string | null;
29872980
imageUrl?: string | null;
29882981
authors?: string | null;
29892982
publisher?: string | null;
@@ -3041,14 +3034,6 @@ export type ProspectDataWithCorpusItemsFragment = {
30413034
createdBy: string;
30423035
createdAt: number;
30433036
} | null;
3044-
item?: {
3045-
__typename?: 'Item';
3046-
givenUrl: any;
3047-
itemId: string;
3048-
normalUrl: string;
3049-
datePublished?: any | null;
3050-
timeToRead?: number | null;
3051-
} | null;
30523037
};
30533038

30543039
export type RejectedItemDataFragment = {
@@ -4315,6 +4300,7 @@ export type UpdateProspectAsCuratedMutation = {
43154300
prospectType: string;
43164301
url: string;
43174302
createdAt?: number | null;
4303+
datePublished?: string | null;
43184304
imageUrl?: string | null;
43194305
authors?: string | null;
43204306
publisher?: string | null;
@@ -4372,14 +4358,6 @@ export type UpdateProspectAsCuratedMutation = {
43724358
createdBy: string;
43734359
createdAt: number;
43744360
} | null;
4375-
item?: {
4376-
__typename?: 'Item';
4377-
givenUrl: any;
4378-
itemId: string;
4379-
normalUrl: string;
4380-
datePublished?: any | null;
4381-
timeToRead?: number | null;
4382-
} | null;
43834361
} | null;
43844362
};
43854363

@@ -4880,6 +4858,7 @@ export type GetProspectsQuery = {
48804858
prospectType: string;
48814859
url: string;
48824860
createdAt?: number | null;
4861+
datePublished?: string | null;
48834862
imageUrl?: string | null;
48844863
authors?: string | null;
48854864
publisher?: string | null;
@@ -4937,14 +4916,6 @@ export type GetProspectsQuery = {
49374916
createdBy: string;
49384917
createdAt: number;
49394918
} | null;
4940-
item?: {
4941-
__typename?: 'Item';
4942-
givenUrl: any;
4943-
itemId: string;
4944-
normalUrl: string;
4945-
datePublished?: any | null;
4946-
timeToRead?: number | null;
4947-
} | null;
49484919
}>;
49494920
};
49504921

@@ -5604,15 +5575,6 @@ export const RejectedItemDataFragmentDoc = gql`
56045575
createdAt
56055576
}
56065577
`;
5607-
export const BasicParserItemDataFragmentDoc = gql`
5608-
fragment BasicParserItemData on Item {
5609-
givenUrl
5610-
itemId
5611-
normalUrl
5612-
datePublished
5613-
timeToRead
5614-
}
5615-
`;
56165578
export const ProspectDataWithCorpusItemsFragmentDoc = gql`
56175579
fragment ProspectDataWithCorpusItems on Prospect {
56185580
id
@@ -5622,6 +5584,7 @@ export const ProspectDataWithCorpusItemsFragmentDoc = gql`
56225584
prospectType
56235585
url
56245586
createdAt
5587+
datePublished
56255588
imageUrl
56265589
authors
56275590
publisher
@@ -5638,13 +5601,9 @@ export const ProspectDataWithCorpusItemsFragmentDoc = gql`
56385601
rejectedCorpusItem {
56395602
...RejectedItemData
56405603
}
5641-
item {
5642-
...BasicParserItemData
5643-
}
56445604
}
56455605
${CuratedItemDataWithHistoryFragmentDoc}
56465606
${RejectedItemDataFragmentDoc}
5647-
${BasicParserItemDataFragmentDoc}
56485607
`;
56495608
export const ScheduledItemDataFragmentDoc = gql`
56505609
fragment ScheduledItemData on ScheduledCorpusItem {

src/curated-corpus/components/ExistingProspectCard/ExistingProspectCard.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ export const ExistingProspectCard: React.FC<ExistingProspectCardProps> = (
109109
</ListItemIcon>
110110
<ListItemText secondary={item.language} />
111111
</ListItem>
112+
<ListItem disableGutters>
113+
<ListItemText
114+
secondary={
115+
item.datePublished &&
116+
`Published ${DateTime.fromJSDate(
117+
new Date(item.datePublished),
118+
).toFormat('MMMM dd, yyyy')}`
119+
}
120+
/>
121+
</ListItem>
112122
<ListItem disableGutters>
113123
<ListItemIcon sx={{ minWidth: '1.5rem' }}>
114124
<FaceIcon fontSize="small" />

src/curated-corpus/components/ProspectFilters/ProspectFilters.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,12 @@ describe('The ProspectFilters component', () => {
138138
expect(switchLabel).toBeInTheDocument();
139139
});
140140

141-
/*
142-
TODO: re-enable after https://mozilla-hub.atlassian.net/browse/HNT-1364
143141
it('should render the sort by published date filter', () => {
144142
renderComponent();
145143

146144
const publishedDate = screen.getByText(/Published Date/i);
147145
expect(publishedDate).toBeInTheDocument();
148146
});
149-
*/
150147

151148
it('should render the topic filter', () => {
152149
renderComponent();

src/curated-corpus/components/ProspectFilters/ProspectFilters.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,9 @@ export const ProspectFilters: React.FC<ProspectFiltersProps> = (
8080
setProspectMetadataFilters,
8181
excludePublisherSwitch,
8282
filterByPublisher,
83-
// remove disable after https://mozilla-hub.atlassian.net/browse/HNT-1364
84-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
8583
sortByPublishedDate,
8684
setFilterByPublisher,
8785
onChange,
88-
// remove disable after https://mozilla-hub.atlassian.net/browse/HNT-1364
89-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
9086
onSortByPublishedDate,
9187
} = props;
9288

@@ -128,10 +124,6 @@ export const ProspectFilters: React.FC<ProspectFiltersProps> = (
128124
labelPlacement={'top'} // Ensures the label is on top of the switch
129125
/>
130126
</FormGroup>
131-
{/*
132-
TODO: uncomment this filter after adding published date to prospect
133-
object
134-
https://mozilla-hub.atlassian.net/browse/HNT-1364
135127
<FormGroup>
136128
<FormControlLabel
137129
sx={{ mx: 2, mb: 2 }}
@@ -145,7 +137,6 @@ export const ProspectFilters: React.FC<ProspectFiltersProps> = (
145137
labelPlacement={'top'} // Ensures the label is on top of the switch
146138
/>
147139
</FormGroup>
148-
*/}
149140
{/*Topic Filter*/}
150141
{prospects.length > 0 && (
151142
<FormGroup sx={{ mx: 1, mb: 2 }}>

src/curated-corpus/components/ProspectListCard/ProspectListCard.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ import { getDisplayTopic } from '../../helpers/topics';
2525
import { RemoveProspectAction } from '../actions/RemoveProspectAction/RemoveProspectAction';
2626
import { useToggle } from '../../../_shared/hooks';
2727

28-
// TODO: uncomment this filter after adding published date to prospect object
29-
// https://mozilla-hub.atlassian.net/browse/HNT-1364
30-
// import { DateTime } from 'luxon';
28+
import { DateTime } from 'luxon';
3129

3230
interface ProspectListCardProps {
3331
/**
@@ -114,10 +112,6 @@ export const ProspectListCard: React.FC<ProspectListCardProps> = (
114112
<ListItemText secondary={prospect.prospectType.toLowerCase()} />
115113
</ListItem>
116114

117-
{/*
118-
TODO: uncomment this filter after adding published date to prospect
119-
object
120-
https://mozilla-hub.atlassian.net/browse/HNT-1364
121115
<ListItem disableGutters>
122116
<ListItemText
123117
secondary={
@@ -128,7 +122,6 @@ export const ProspectListCard: React.FC<ProspectListCardProps> = (
128122
}
129123
/>
130124
</ListItem>
131-
*/}
132125
</List>
133126
</Grid>
134127
<Grid item xs={12} sm={9}>

src/curated-corpus/pages/ProspectingPage/ProspectingPage.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import { transformAuthors } from '../../../_shared/utils/transformAuthors';
5454
import { getDisplayTopic } from '../../helpers/topics';
5555
import { ProspectFilterOptions } from '../../components/ProspectFilters/ProspectFilters';
5656

57-
const distantPast = new Date('1970-01-01Z00:00:00:000').getTime();
57+
const distantPast = new Date('1970-01-01T00:00:00').getTime();
5858

5959
export const ProspectingPage: React.FC = (): JSX.Element => {
6060
const initialProspectFiltersState: ProspectFilterOptions = {
@@ -640,10 +640,11 @@ export const ProspectingPage: React.FC = (): JSX.Element => {
640640
const handleSortByPublishedDate = (prospectList: Prospect[]) => {
641641
const sortedProspects = [...(prospectList || [])].sort((a, b) => {
642642
return (
643-
new Date(b.item?.datePublished ?? distantPast).getTime() -
644-
new Date(a.item?.datePublished ?? distantPast).getTime()
643+
new Date(b.datePublished ?? distantPast).getTime() -
644+
new Date(a.datePublished ?? distantPast).getTime()
645645
);
646646
});
647+
647648
setProspects(sortedProspects);
648649
};
649650

0 commit comments

Comments
 (0)