Skip to content

Commit 8a3e53b

Browse files
committed
Count the papers of recommenders
Signed-off-by: Jay Wang <[email protected]>
1 parent f28b5f5 commit 8a3e53b

27 files changed

+257
-54
lines changed

src/api/semantic-scholar.ts

+18-15
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ import { downloadJSON } from '@xiaohk/utils';
1010

1111
import paperSearchMockJSON from '../../test/api-responses/paper-search.json';
1212
import citationSearchMockJSON from '../../test/api-responses/citation-search.json';
13-
import authorCitationSearchMockJSON0 from '../../test/api-responses/author-citation-search-8-0.json';
14-
import authorCitationSearchMockJSON1 from '../../test/api-responses/author-citation-search-8-1.json';
15-
import authorCitationSearchMockJSON2 from '../../test/api-responses/author-citation-search-8-2.json';
16-
import authorCitationSearchMockJSON3 from '../../test/api-responses/author-citation-search-8-3.json';
17-
import authorCitationSearchMockJSON4 from '../../test/api-responses/author-citation-search-8-4.json';
18-
import authorCitationSearchMockJSON5 from '../../test/api-responses/author-citation-search-8-5.json';
19-
import authorCitationSearchMockJSON6 from '../../test/api-responses/author-citation-search-8-6.json';
20-
import authorCitationSearchMockJSON7 from '../../test/api-responses/author-citation-search-8-7.json';
21-
import authorCitationSearchMockJSON8 from '../../test/api-responses/author-citation-search-8-8.json';
22-
23-
const MOCK_HTTP_CALL = false;
13+
import authorCitationSearchMockJSON0 from '../../test/api-responses/author-citation-search-9-0.json';
14+
import authorCitationSearchMockJSON1 from '../../test/api-responses/author-citation-search-9-1.json';
15+
import authorCitationSearchMockJSON2 from '../../test/api-responses/author-citation-search-9-2.json';
16+
import authorCitationSearchMockJSON3 from '../../test/api-responses/author-citation-search-9-3.json';
17+
import authorCitationSearchMockJSON4 from '../../test/api-responses/author-citation-search-9-4.json';
18+
import authorCitationSearchMockJSON5 from '../../test/api-responses/author-citation-search-9-5.json';
19+
import authorCitationSearchMockJSON6 from '../../test/api-responses/author-citation-search-9-6.json';
20+
import authorCitationSearchMockJSON7 from '../../test/api-responses/author-citation-search-9-7.json';
21+
import authorCitationSearchMockJSON8 from '../../test/api-responses/author-citation-search-9-8.json';
22+
import authorCitationSearchMockJSON9 from '../../test/api-responses/author-citation-search-9-9.json';
23+
24+
const MOCK_HTTP_CALL = true;
2425

2526
const paperSearchMock = paperSearchMockJSON as SemanticPaperSearchResponse;
2627
const citationSearchMock =
@@ -36,7 +37,8 @@ const authorCitationSearchMocks = [
3637
authorCitationSearchMockJSON5 as SemanticAuthorDetail[],
3738
authorCitationSearchMockJSON6 as SemanticAuthorDetail[],
3839
authorCitationSearchMockJSON7 as SemanticAuthorDetail[],
39-
authorCitationSearchMockJSON8 as SemanticAuthorDetail[]
40+
authorCitationSearchMockJSON8 as SemanticAuthorDetail[],
41+
authorCitationSearchMockJSON9 as SemanticAuthorDetail[]
4042
];
4143

4244
/**
@@ -104,13 +106,14 @@ export const searchAuthorDetails = async (
104106
try {
105107
const response = await fetch(url, options);
106108
const data = (await response.json()) as SemanticAuthorDetail[];
109+
110+
// downloadJSON(data, null, 'author.json');
111+
107112
return data;
108113
} catch (e) {
109114
console.error('API error', e);
110115
throw new Error(`Fetch error when getting author details, status: ${e}`);
111116
}
112-
113-
// downloadJSON(data, null, 'author.json');
114117
};
115118

116119
export const getAllPapersFromAuthor = async (authorID: string) => {
@@ -171,7 +174,7 @@ export const getPaperCitations = async (paperIDs: string[]) => {
171174

172175
const baseURL = 'https://api.semanticscholar.org/graph/v1/paper/batch';
173176
const parameters: Record<string, string> = {
174-
fields: 'paperId,citations.authors'
177+
fields: 'paperId,citations.authors,citations.title'
175178
};
176179
const encodedParameters = new URLSearchParams(parameters);
177180

src/components/recommender-view/recommender-view.css

+38-4
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@
319319
gap: 2px;
320320
}
321321

322+
&.paper-count {
323+
gap: 2px;
324+
.svg-icon {
325+
width: 0.8em;
326+
height: 0.8em;
327+
}
328+
}
329+
322330
&:hover {
323331
background-color: var(--gray-200);
324332
}
@@ -454,17 +462,43 @@ button {
454462
max-width: 300px;
455463
max-height: 200px;
456464
line-height: 1.5;
465+
466+
padding: 2px 0;
467+
box-sizing: border-box;
468+
user-select: none;
469+
-webkit-user-select: none;
470+
471+
display: flex;
472+
flex-flow: column;
473+
}
474+
475+
.table-title {
476+
padding: 0 2px;
477+
display: flex;
478+
justify-content: space-between;
479+
box-sizing: border-box;
480+
}
481+
482+
.separator {
483+
width: 100%;
484+
background: var(--gray-600);
485+
height: 1px;
486+
margin: 3px 0;
487+
}
488+
489+
.paper-table {
490+
width: 100%;
491+
flex: 1;
492+
padding: 0 2px;
493+
box-sizing: border-box;
494+
457495
overflow-x: hidden;
458496
overflow-y: auto;
459497

460498
display: grid;
461499
grid-template-columns: auto min-content;
462500
column-gap: 3px;
463501
row-gap: 2px;
464-
padding: 2px;
465-
466-
user-select: none;
467-
-webkit-user-select: none;
468502
}
469503

470504
.popper-arrow {

0 commit comments

Comments
 (0)