Skip to content

Commit 44447ad

Browse files
committed
optional-citation
1 parent fe72c48 commit 44447ad

7 files changed

Lines changed: 38 additions & 18 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "2"
33
members = ["crates/cli", "crates/core", "crates/wasm/overlay"]
44

55
[workspace.package]
6-
version = "0.9.3"
6+
version = "0.9.4"
77
license = "Apache-2.0"
88
edition = "2021"
99
rust-version = "1.77"

crates/cli/src/build/api.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,12 @@ impl From<&data::Location> for Location {
404404
pub(crate) struct Academic {
405405
pub name: String,
406406
pub profile_url: String,
407-
pub hindex: i32,
408-
pub citations: i32,
407+
408+
#[serde(skip_serializing_if = "Option::is_none")]
409+
pub hindex: Option<i32>,
410+
411+
#[serde(skip_serializing_if = "Option::is_none")]
412+
pub citations: Option<i32>,
409413

410414
#[serde(skip_serializing_if = "Option::is_none")]
411415
pub i10index: Option<i32>,

crates/core/src/data.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,12 @@ pub struct Item {
691691
pub struct Academic {
692692
pub name: String,
693693
pub profile_url: String,
694-
pub hindex: i32,
695-
pub citations: i32,
694+
695+
#[serde(skip_serializing_if = "Option::is_none")]
696+
pub hindex: Option<i32>,
697+
698+
#[serde(skip_serializing_if = "Option::is_none")]
699+
pub citations: Option<i32>,
696700

697701
#[serde(skip_serializing_if = "Option::is_none")]
698702
pub i10index: Option<i32>,

crates/core/src/data/legacy.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,12 @@ pub(crate) struct Location {
158158
pub(crate) struct Academic {
159159
pub name: String,
160160
pub profile_url: String,
161-
pub hindex: i32,
162-
pub citations: i32,
161+
162+
#[serde(skip_serializing_if = "Option::is_none")]
163+
pub hindex: Option<i32>,
164+
165+
#[serde(skip_serializing_if = "Option::is_none")]
166+
pub citations: Option<i32>,
163167

164168
#[serde(skip_serializing_if = "Option::is_none")]
165169
pub i10index: Option<i32>,

src/build/data.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,12 @@ pub(crate) struct Location {
640640
pub(crate) struct Academic {
641641
pub name: String,
642642
pub profile_url: String,
643-
pub hindex: i32,
644-
pub citations: i32,
643+
644+
#[serde(skip_serializing_if = "Option::is_none")]
645+
pub hindex: Option<i32>,
646+
647+
#[serde(skip_serializing_if = "Option::is_none")]
648+
pub citations: Option<i32>,
645649

646650
#[serde(skip_serializing_if = "Option::is_none")]
647651
pub i10index: Option<i32>,
@@ -930,8 +934,12 @@ mod legacy {
930934
pub(crate) struct Academic {
931935
pub name: String,
932936
pub profile_url: String,
933-
pub hindex: i32,
934-
pub citations: i32,
937+
938+
#[serde(skip_serializing_if = "Option::is_none")]
939+
pub hindex: Option<i32>,
940+
941+
#[serde(skip_serializing_if = "Option::is_none")]
942+
pub citations: Option<i32>,
935943

936944
#[serde(skip_serializing_if = "Option::is_none")]
937945
pub i10index: Option<i32>,

ui/webapp/src/layout/common/itemModal/AcademicSection.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const AcademicSection = (props: Props) => {
2626
</div>
2727

2828
<div class="row g-4 my-0 mb-2">
29-
<Box value={prettifyNumber(primary()!.citations, 1)} legend="Citations" />
30-
<Box value={prettifyNumber(primary()!.hindex, 1)} legend="h-index" />
29+
<Box value={!isUndefined(primary()!.citations) ? prettifyNumber(primary()!.citations!, 1) : "-"} legend="Citations" />
30+
<Box value={!isUndefined(primary()!.hindex) ? prettifyNumber(primary()!.hindex!, 1) : "-"} legend="h-index" />
3131
<Box value={!isUndefined(primary()!.i10index) ? prettifyNumber(primary()!.i10index!, 1) : "-"} legend="i10-index" />
3232
</div>
3333

@@ -64,8 +64,8 @@ const AcademicSection = (props: Props) => {
6464
{q.name}
6565
</ExternalLink>
6666
</td>
67-
<td class="px-3 text-center text-nowrap">{prettifyNumber(q.citations, 1)}</td>
68-
<td class="px-3 text-center text-nowrap">{prettifyNumber(q.hindex, 1)}</td>
67+
<td class="px-3 text-center text-nowrap">{!isUndefined(q.citations) ? prettifyNumber(q.citations!, 1) : "-"}</td>
68+
<td class="px-3 text-center text-nowrap">{!isUndefined(q.hindex) ? prettifyNumber(q.hindex!, 1) : "-"}</td>
6969
<td class="px-3 text-center text-nowrap">{!isUndefined(q.i10index) ? prettifyNumber(q.i10index!, 1) : "-"}</td>
7070
</tr>
7171
);

0 commit comments

Comments
 (0)