Skip to content

Commit 6589a1a

Browse files
authored
feat(HNT-1363): remove parser dependency (#1264)
* feat(HNT-1363): remove parser dependency - removes time to read (not available from zyte) - retrieves datePublished from the prospect-api graph (not parser)
1 parent c5f79c4 commit 6589a1a

File tree

10 files changed

+22
-254
lines changed

10 files changed

+22
-254
lines changed

src/api/fragments/BasicParserItemData.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/api/fragments/prospectWithCorpusItems.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { gql } from '@apollo/client';
22
import { CuratedItemDataWithHistory } from './CuratedItemWithHistory';
33
import { RejectedItemData } from './rejectedItemData';
4-
import { BasicParserItemData } from './BasicParserItemData';
54

65
/**
76
* Everything we need to fetch for a Prospect, including optional
@@ -16,6 +15,7 @@ export const ProspectDataWithCorpusItems = gql`
1615
prospectType
1716
url
1817
createdAt
18+
datePublished
1919
imageUrl
2020
authors
2121
publisher
@@ -32,11 +32,7 @@ export const ProspectDataWithCorpusItems = gql`
3232
rejectedCorpusItem {
3333
...RejectedItemData
3434
}
35-
item {
36-
...BasicParserItemData
37-
}
3835
}
3936
${CuratedItemDataWithHistory}
4037
${RejectedItemData}
41-
${BasicParserItemData}
4238
`;

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.test.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ describe('The ExistingProspectCard component', () => {
6767
<MemoryRouter>
6868
<ExistingProspectCard
6969
item={prospect.approvedCorpusItem!}
70-
parserItem={prospect.item!}
7170
prospectId={prospect.prospectId}
7271
onSchedule={onSchedule}
7372
onRemoveProspect={onRemoveProspect}
@@ -100,7 +99,6 @@ describe('The ExistingProspectCard component', () => {
10099
<MemoryRouter>
101100
<ExistingProspectCard
102101
item={prospect.approvedCorpusItem!}
103-
parserItem={prospect.item!}
104102
prospectId={prospect.prospectId}
105103
onSchedule={onSchedule}
106104
onRemoveProspect={onRemoveProspect}
@@ -120,7 +118,6 @@ describe('The ExistingProspectCard component', () => {
120118
<MemoryRouter>
121119
<ExistingProspectCard
122120
item={prospect.approvedCorpusItem!}
123-
parserItem={prospect.item!}
124121
prospectId={prospect.prospectId}
125122
onSchedule={onSchedule}
126123
onRemoveProspect={onRemoveProspect}
@@ -140,7 +137,6 @@ describe('The ExistingProspectCard component', () => {
140137
<MemoryRouter>
141138
<ExistingProspectCard
142139
item={prospect.approvedCorpusItem!}
143-
parserItem={prospect.item!}
144140
prospectId={prospect.prospectId}
145141
onSchedule={onSchedule}
146142
onRemoveProspect={onRemoveProspect}
@@ -160,7 +156,6 @@ describe('The ExistingProspectCard component', () => {
160156
<MemoryRouter>
161157
<ExistingProspectCard
162158
item={prospect.approvedCorpusItem!}
163-
parserItem={prospect.item!}
164159
prospectId={prospect.prospectId}
165160
onSchedule={onSchedule}
166161
onRemoveProspect={onRemoveProspect}
@@ -183,7 +178,6 @@ describe('The ExistingProspectCard component', () => {
183178
<MemoryRouter>
184179
<ExistingProspectCard
185180
item={prospect.approvedCorpusItem!}
186-
parserItem={prospect.item!}
187181
prospectId={prospect.prospectId}
188182
onSchedule={onSchedule}
189183
onRemoveProspect={onRemoveProspect}
@@ -203,7 +197,6 @@ describe('The ExistingProspectCard component', () => {
203197
<MemoryRouter>
204198
<ExistingProspectCard
205199
item={prospect.approvedCorpusItem!}
206-
parserItem={prospect.item!}
207200
prospectId={prospect.prospectId}
208201
onSchedule={onSchedule}
209202
onRemoveProspect={onRemoveProspect}
@@ -252,7 +245,6 @@ describe('The ExistingProspectCard component', () => {
252245
<MemoryRouter>
253246
<ExistingProspectCard
254247
item={prospectWithScheduleHistory.approvedCorpusItem!}
255-
parserItem={prospect.item!}
256248
prospectId={prospect.prospectId}
257249
onSchedule={onSchedule}
258250
onRemoveProspect={onRemoveProspect}

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';
2020
import { DateTime } from 'luxon';
2121

2222
import { curationPalette } from '../../../theme';
23-
import { ApprovedCorpusItem, Item } from '../../../api/generatedTypes';
23+
import { ApprovedCorpusItem } from '../../../api/generatedTypes';
2424
import { Button } from '../../../_shared/components';
2525
import { getCuratorNameFromLdap } from '../../helpers/helperFunctions';
2626
import { ScheduleHistory } from '../ScheduleHistory/ScheduleHistory';
@@ -34,11 +34,6 @@ interface ExistingProspectCardProps {
3434
* An object with everything approved curated item-related in it.
3535
*/
3636
item: ApprovedCorpusItem;
37-
38-
/**
39-
* An object with details from the parser
40-
*/
41-
parserItem: Item;
4237
/**
4338
* This is the prospect.id and NOT prospect.prospectId
4439
*/
@@ -73,7 +68,6 @@ export const ExistingProspectCard: React.FC<ExistingProspectCardProps> = (
7368
): JSX.Element => {
7469
const {
7570
item,
76-
parserItem,
7771
onSchedule,
7872
onRemoveProspect,
7973
prospectId,
@@ -118,9 +112,9 @@ export const ExistingProspectCard: React.FC<ExistingProspectCardProps> = (
118112
<ListItem disableGutters>
119113
<ListItemText
120114
secondary={
121-
parserItem?.datePublished &&
115+
item.datePublished &&
122116
`Published ${DateTime.fromJSDate(
123-
new Date(parserItem?.datePublished),
117+
new Date(item.datePublished),
124118
).toFormat('MMMM dd, yyyy')}`
125119
}
126120
/>

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ describe('The ProspectFilters component', () => {
9393
const onChange = jest.fn();
9494
const onSortByPublishedDate = jest.fn();
9595
const sortByPublishedDate = false;
96-
const sortByTimeToRead = false;
97-
const handleSortByTimeToRead = jest.fn();
9896

9997
// const mockSetFilters = jest.fn();
10098
//
@@ -114,8 +112,6 @@ describe('The ProspectFilters component', () => {
114112
onChange={onChange}
115113
onSortByPublishedDate={onSortByPublishedDate}
116114
sortByPublishedDate={sortByPublishedDate}
117-
sortByTimeToRead={sortByTimeToRead}
118-
handleSortByTimeToRead={handleSortByTimeToRead}
119115
/>,
120116
);
121117
};
@@ -149,13 +145,6 @@ describe('The ProspectFilters component', () => {
149145
expect(publishedDate).toBeInTheDocument();
150146
});
151147

152-
it('should render the sort by time to read filter', () => {
153-
renderComponent();
154-
155-
const timeToRead = screen.getByText(/Time to Read/i);
156-
expect(timeToRead).toBeInTheDocument();
157-
});
158-
159148
it('should render the topic filter', () => {
160149
renderComponent();
161150

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,6 @@ interface ProspectFiltersProps {
6363
* in the parent component (Prospecting page).
6464
*/
6565
sortByPublishedDate: boolean;
66-
67-
/**
68-
* Boolean flag to represent the state of sortByTimeToRead toggle in the parent component
69-
* (prospecting page)
70-
*/
71-
sortByTimeToRead: boolean;
72-
73-
/**
74-
* Function to toggle sortByTimeToRead in the parent component (prospecting page)
75-
*/
76-
handleSortByTimeToRead: VoidFunction;
7766
}
7867

7968
/**
@@ -95,8 +84,6 @@ export const ProspectFilters: React.FC<ProspectFiltersProps> = (
9584
setFilterByPublisher,
9685
onChange,
9786
onSortByPublishedDate,
98-
sortByTimeToRead,
99-
handleSortByTimeToRead,
10087
} = props;
10188

10289
// Extract all topics from prospects item data
@@ -150,19 +137,6 @@ export const ProspectFilters: React.FC<ProspectFiltersProps> = (
150137
labelPlacement={'top'} // Ensures the label is on top of the switch
151138
/>
152139
</FormGroup>
153-
<FormGroup>
154-
<FormControlLabel
155-
sx={{ mx: 2, mb: 2 }}
156-
control={
157-
<Switch
158-
checked={sortByTimeToRead}
159-
onChange={handleSortByTimeToRead}
160-
/>
161-
}
162-
label={'Time to Read'}
163-
labelPlacement={'top'} // Ensures the label is on top of the switch
164-
/>
165-
</FormGroup>
166140
{/*Topic Filter*/}
167141
{prospects.length > 0 && (
168142
<FormGroup sx={{ mx: 1, mb: 2 }}>

0 commit comments

Comments
 (0)