Skip to content

Commit bd0166a

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 d0409e3 commit bd0166a

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
@@ -1641,6 +1641,7 @@ export type Prospect = {
16411641
approvedCorpusItem?: Maybe<ApprovedCorpusItem>;
16421642
authors?: Maybe<Scalars['String']>;
16431643
createdAt?: Maybe<Scalars['Int']>;
1644+
datePublished?: Maybe<Scalars['String']>;
16441645
domain?: Maybe<Scalars['String']>;
16451646
excerpt?: Maybe<Scalars['String']>;
16461647
id: Scalars['ID'];
@@ -2635,15 +2636,6 @@ export enum Videoness {
26352636
NoVideos = 'NO_VIDEOS',
26362637
}
26372638

2638-
export type BasicParserItemDataFragment = {
2639-
__typename?: 'Item';
2640-
givenUrl: any;
2641-
itemId: string;
2642-
normalUrl: string;
2643-
datePublished?: any | null;
2644-
timeToRead?: number | null;
2645-
};
2646-
26472639
export type CollectionAuthorDataFragment = {
26482640
__typename?: 'CollectionAuthor';
26492641
externalId: string;
@@ -3038,6 +3030,7 @@ export type ProspectDataWithCorpusItemsFragment = {
30383030
prospectType: string;
30393031
url: string;
30403032
createdAt?: number | null;
3033+
datePublished?: string | null;
30413034
imageUrl?: string | null;
30423035
authors?: string | null;
30433036
publisher?: string | null;
@@ -3095,14 +3088,6 @@ export type ProspectDataWithCorpusItemsFragment = {
30953088
createdBy: string;
30963089
createdAt: number;
30973090
} | null;
3098-
item?: {
3099-
__typename?: 'Item';
3100-
givenUrl: any;
3101-
itemId: string;
3102-
normalUrl: string;
3103-
datePublished?: any | null;
3104-
timeToRead?: number | null;
3105-
} | null;
31063091
};
31073092

31083093
export type RejectedItemDataFragment = {
@@ -4386,6 +4371,7 @@ export type UpdateProspectAsCuratedMutation = {
43864371
prospectType: string;
43874372
url: string;
43884373
createdAt?: number | null;
4374+
datePublished?: string | null;
43894375
imageUrl?: string | null;
43904376
authors?: string | null;
43914377
publisher?: string | null;
@@ -4443,14 +4429,6 @@ export type UpdateProspectAsCuratedMutation = {
44434429
createdBy: string;
44444430
createdAt: number;
44454431
} | null;
4446-
item?: {
4447-
__typename?: 'Item';
4448-
givenUrl: any;
4449-
itemId: string;
4450-
normalUrl: string;
4451-
datePublished?: any | null;
4452-
timeToRead?: number | null;
4453-
} | null;
44544432
} | null;
44554433
};
44564434

@@ -4951,6 +4929,7 @@ export type GetProspectsQuery = {
49514929
prospectType: string;
49524930
url: string;
49534931
createdAt?: number | null;
4932+
datePublished?: string | null;
49544933
imageUrl?: string | null;
49554934
authors?: string | null;
49564935
publisher?: string | null;
@@ -5008,14 +4987,6 @@ export type GetProspectsQuery = {
50084987
createdBy: string;
50094988
createdAt: number;
50104989
} | null;
5011-
item?: {
5012-
__typename?: 'Item';
5013-
givenUrl: any;
5014-
itemId: string;
5015-
normalUrl: string;
5016-
datePublished?: any | null;
5017-
timeToRead?: number | null;
5018-
} | null;
50194990
}>;
50204991
};
50214992

@@ -5675,15 +5646,6 @@ export const RejectedItemDataFragmentDoc = gql`
56755646
createdAt
56765647
}
56775648
`;
5678-
export const BasicParserItemDataFragmentDoc = gql`
5679-
fragment BasicParserItemData on Item {
5680-
givenUrl
5681-
itemId
5682-
normalUrl
5683-
datePublished
5684-
timeToRead
5685-
}
5686-
`;
56875649
export const ProspectDataWithCorpusItemsFragmentDoc = gql`
56885650
fragment ProspectDataWithCorpusItems on Prospect {
56895651
id
@@ -5693,6 +5655,7 @@ export const ProspectDataWithCorpusItemsFragmentDoc = gql`
56935655
prospectType
56945656
url
56955657
createdAt
5658+
datePublished
56965659
imageUrl
56975660
authors
56985661
publisher
@@ -5709,13 +5672,9 @@ export const ProspectDataWithCorpusItemsFragmentDoc = gql`
57095672
rejectedCorpusItem {
57105673
...RejectedItemData
57115674
}
5712-
item {
5713-
...BasicParserItemData
5714-
}
57155675
}
57165676
${CuratedItemDataWithHistoryFragmentDoc}
57175677
${RejectedItemDataFragmentDoc}
5718-
${BasicParserItemDataFragmentDoc}
57195678
`;
57205679
export const ScheduledItemDataFragmentDoc = gql`
57215680
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)