Skip to content

Commit

Permalink
fix: Issues with parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
vxern committed Jun 9, 2024
1 parent 95bb92d commit e4ee803
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/tatoeba/search.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -251,26 +251,28 @@ fn complete_sort(
/// data if it does.
///
fn paging(from data: Dynamic) -> Result(Paging, List(dynamic.DecodeError)) {
use data <- result.try(data |> field("Sentences", dynamic.dynamic))

use finder <- result.try(data |> field("finder", finder))
use page <- result.try(data |> field("page", int))
use results_on_current_page <- result.try(data |> field("current", int))
use result_count <- result.try(data |> field("count", int))
use results_per_page <- result.try(data |> field("per_page", int))
use results_per_page <- result.try(data |> field("perPage", int))
use start <- result.try(data |> field("start", int))
use end <- result.try(data |> field("end", int))
use previous_page <- result.try(data |> field("previous_page", bool))
use next_page <- result.try(data |> field("next_page", bool))
use page_count <- result.try(data |> field("page_count", int))
use previous_page <- result.try(data |> field("prevPage", bool))
use next_page <- result.try(data |> field("nextPage", bool))
use page_count <- result.try(data |> field("pageCount", int))
use sort_strategy <- result.try(
data |> field("sort", optional(sort_strategy)),
)
use direction <- result.try(data |> field("direction", optional(bool)))
use limit <- result.try(data |> field("limit", optional(limit)))
use sort_default <- result.try(data |> field("sort_default", bool))
use direction_default <- result.try(data |> field("direction_default", bool))
use sort_default <- result.try(data |> field("sortDefault", bool))
use direction_default <- result.try(data |> field("directionDefault", bool))
use scope <- result.try(data |> field("scope", optional(scope)))
use complete_sort <- result.try(
data |> field("complete_sort", list(complete_sort)),
data |> field("completeSort", list(complete_sort)),
)

Ok(Paging(
Expand Down
6 changes: 4 additions & 2 deletions src/tatoeba/sentence.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ pub fn sentence(
use language_name <- result.try(data |> field("lang_name", string))
use script <- result.try(data |> field("script", optional(string)))
use license <- result.try(data |> field("license", string))
use based_on_id <- result.try(data |> field("based_on_id", optional(int)))
use based_on_id <- result.try(
data |> optional_field("based_on_id", optional(int)),
)
// use base <- result.try(data |> field("base", optional(sentence)))
use correctness <- result.try(data |> field("correctness", int))
use translations <- result.try(data |> field("translations", translations))
Expand Down Expand Up @@ -513,7 +515,7 @@ pub fn sentence(
language_name: language_name,
script: script,
license: license,
based_on_id: based_on_id,
based_on_id: based_on_id |> option.flatten(),
// base: base,
correctness: correctness,
translations: translations,
Expand Down

0 comments on commit e4ee803

Please sign in to comment.