Skip to content

Commit

Permalink
Optional value type
Browse files Browse the repository at this point in the history
  • Loading branch information
roxy-dao committed Nov 14, 2024
1 parent aade948 commit 7c7636c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions server/graphql/types/src/types/program/program_indicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ impl IndicatorLineRowNode {
pub async fn line_number(&self) -> i32 {
self.line.line_number
}

pub async fn value_type(&self) -> Option<IndicatorValueTypeNode> {
IndicatorValueTypeNode::from_domain(&self.line.value_type)
}
}

impl IndicatorColumnNode {
Expand All @@ -174,7 +178,7 @@ impl IndicatorColumnNode {
&self.column.header
}

pub async fn value_type(&self) -> IndicatorValueTypeNode {
pub async fn value_type(&self) -> Option<IndicatorValueTypeNode> {
IndicatorValueTypeNode::from_domain(&self.column.value_type)
}

Expand Down Expand Up @@ -219,11 +223,11 @@ pub enum IndicatorValueTypeNode {
}

impl IndicatorValueTypeNode {
pub fn from_domain(r#type: &Option<IndicatorValueType>) -> Self {
pub fn from_domain(r#type: &Option<IndicatorValueType>) -> Option<Self> {
match r#type {
Some(IndicatorValueType::Number) => IndicatorValueTypeNode::Number,
Some(IndicatorValueType::String) => IndicatorValueTypeNode::String,
None => IndicatorValueTypeNode::String,
Some(IndicatorValueType::Number) => Some(IndicatorValueTypeNode::Number),
Some(IndicatorValueType::String) => Some(IndicatorValueTypeNode::String),
None => None,
}
}
}
Expand Down

0 comments on commit 7c7636c

Please sign in to comment.