Skip to content

Commit 0af49ef

Browse files
committed
Sort by paper count
Signed-off-by: Jay Wang <[email protected]>
1 parent 8a3e53b commit 0af49ef

File tree

3 files changed

+66
-15
lines changed

3 files changed

+66
-15
lines changed

src/api/semantic-scholar.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import authorCitationSearchMockJSON7 from '../../test/api-responses/author-citat
2121
import authorCitationSearchMockJSON8 from '../../test/api-responses/author-citation-search-9-8.json';
2222
import authorCitationSearchMockJSON9 from '../../test/api-responses/author-citation-search-9-9.json';
2323

24-
const MOCK_HTTP_CALL = true;
24+
const MOCK_HTTP_CALL = false;
2525

2626
const paperSearchMock = paperSearchMockJSON as SemanticPaperSearchResponse;
2727
const citationSearchMock =

src/components/recommender-view/recommender-view.ts

+57-6
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ export class RecRecRecommenderView extends LitElement {
137137
remainTimeMS = DEFAULT_REMAIN_TIME;
138138

139139
// Slider ranges
140+
@state()
141+
paperCountRange: SliderRange = {
142+
min: 1,
143+
max: 2,
144+
curValue: 1,
145+
initialValue: 1
146+
};
147+
140148
@state()
141149
citationTimeRange: SliderRange = {
142150
min: 1,
@@ -155,7 +163,7 @@ export class RecRecRecommenderView extends LitElement {
155163

156164
// Sorting and filter
157165
@state()
158-
sortBy: 'citeTimes' | 'hIndex' = 'citeTimes';
166+
sortBy: 'citeTimes' | 'hIndex' | 'paperCount' = 'paperCount';
159167

160168
curShownCardSizeMultiplier = 1;
161169

@@ -249,6 +257,13 @@ export class RecRecRecommenderView extends LitElement {
249257
this.remainTimeMS = DEFAULT_REMAIN_TIME;
250258

251259
// Reset the sliders and checkboxes
260+
this.paperCountRange = {
261+
min: 1,
262+
max: 2,
263+
curValue: 1,
264+
initialValue: 1
265+
};
266+
252267
this.citationTimeRange = {
253268
min: 1,
254269
max: 2,
@@ -564,6 +579,9 @@ export class RecRecRecommenderView extends LitElement {
564579
this.citationTimeRange.min = minCitationTimes;
565580
this.citationTimeRange.max = maxCitationTimes;
566581

582+
this.paperCountRange.min = minPaperCount;
583+
this.paperCountRange.max = maxPaperCount;
584+
567585
this.checkedSelectedPaperIDs = structuredClone(this.selectedPaperIDs);
568586

569587
// Update the view
@@ -617,6 +635,8 @@ export class RecRecRecommenderView extends LitElement {
617635
}
618636

619637
// Slider filters
638+
const paperCountOK =
639+
recommender.paperCount! >= this.paperCountRange.curValue;
620640
const hIndexOK = recommender.hIndex! >= this.hIndexRange.curValue;
621641
const citeTimesOK =
622642
recommender.citeTimes! >= this.citationTimeRange.curValue;
@@ -635,6 +655,7 @@ export class RecRecRecommenderView extends LitElement {
635655
recommender.affiliation !== undefined);
636656

637657
if (
658+
paperCountOK &&
638659
hIndexOK &&
639660
citeTimesOK &&
640661
excludeCollaboratorOK &&
@@ -650,6 +671,8 @@ export class RecRecRecommenderView extends LitElement {
650671
recommenders.sort((a, b) => b.citeTimes! - a.citeTimes!);
651672
} else if (this.sortBy === 'hIndex') {
652673
recommenders.sort((a, b) => b.hIndex! - a.hIndex!);
674+
} else if (this.sortBy === 'paperCount') {
675+
recommenders.sort((a, b) => b.paperCount! - a.paperCount!);
653676
}
654677

655678
this.curRecommendersSize = recommenders.length;
@@ -682,10 +705,22 @@ export class RecRecRecommenderView extends LitElement {
682705
this.updateCitationView();
683706
}
684707

708+
paperCountSliderChanged(e: CustomEvent<number>) {
709+
const count = Math.round(e.detail);
710+
const newPaperCountRange = { ...this.paperCountRange };
711+
newPaperCountRange.curValue = count;
712+
this.paperCountRange = newPaperCountRange;
713+
714+
// Trigger a new recommender view update
715+
this.updateCitationView();
716+
}
717+
685718
selectChanged(e: InputEvent) {
686719
const curValue = (e.currentTarget as HTMLSelectElement).value;
687720
if (curValue === 'hIndex') {
688-
this.sortBy = curValue;
721+
this.sortBy = 'hIndex';
722+
} else if (curValue === 'paperCount') {
723+
this.sortBy = 'paperCount';
689724
} else {
690725
this.sortBy = 'citeTimes';
691726
}
@@ -974,7 +1009,8 @@ export class RecRecRecommenderView extends LitElement {
9741009
this.selectChanged(e);
9751010
}}
9761011
>
977-
<option value="citeTimes">Citing my works</option>
1012+
<option value="paperCount">Papers citing me</option>
1013+
<option value="citeTimes">Times citing me</option>
9781014
<option value="hIndex">H-Index</option>
9791015
</select>
9801016
</div>
@@ -986,7 +1022,22 @@ export class RecRecRecommenderView extends LitElement {
9861022
<div class="control-section control-section-slider">
9871023
<div class="control-block slider-block">
9881024
<div class="citation-slider-label">
989-
Cited my works${this.citationTimeRange.curValue} times
1025+
Papers citing my work${this.paperCountRange.curValue}
1026+
</div>
1027+
<nightjar-slider
1028+
id="slider-paper-count"
1029+
@valueChanged=${(e: CustomEvent<number>) =>
1030+
this.paperCountSliderChanged(e)}
1031+
min=${this.paperCountRange.min}
1032+
max=${this.paperCountRange.max}
1033+
curValue=${this.paperCountRange.initialValue}
1034+
.styleConfig=${SLIDER_STYLE}
1035+
></nightjar-slider>
1036+
</div>
1037+
1038+
<div class="control-block slider-block">
1039+
<div class="citation-slider-label">
1040+
Cited my work${this.citationTimeRange.curValue} times
9901041
</div>
9911042
<nightjar-slider
9921043
id="slider-citation-time"
@@ -1087,8 +1138,8 @@ export class RecRecRecommenderView extends LitElement {
10871138
<div class="table-title">
10881139
<span
10891140
>${this.overlayPaperCountsType === 'citeTimes'
1090-
? 'My papers & Citations by the recommender'
1091-
: "Recommender's papers & Citations of my work"}</span
1141+
? 'My papers & citations by the recommender'
1142+
: "Recommender's papers & citations of my work"}</span
10921143
>
10931144
</div>
10941145

src/components/recrec/recrec.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ export class RecRecApp extends LitElement {
5353
//==========================================================================||
5454
constructor() {
5555
super();
56-
this.selectedProfile = {
57-
authorId: '1390877819',
58-
name: 'Zijie J. Wang',
59-
affiliations: ['Georgia Tech'],
60-
homepage: 'https://zijie.wang',
61-
paperCount: 42,
62-
citationCount: 1716
63-
};
56+
// this.selectedProfile = {
57+
// authorId: '1390877819',
58+
// name: 'Zijie J. Wang',
59+
// affiliations: ['Georgia Tech'],
60+
// homepage: 'https://zijie.wang',
61+
// paperCount: 42,
62+
// citationCount: 1716
63+
// };
6464
}
6565

6666
/**

0 commit comments

Comments
 (0)