Skip to content

Commit

Permalink
Always include nilable field in JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
akadusei committed Sep 15, 2023
1 parent 4bace6e commit 6cd0d42
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mel/cron_task.cr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Mel::CronTask
json.field("retries", retries)
json.field("attempts", attempts)
json.field("schedule", schedule)
json.field("till", till.try(&.to_unix)) if till
json.field("till", till.try(&.to_unix))
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/mel/periodic_task.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Mel::PeriodicTask
json.field("retries", retries)
json.field("attempts", attempts)
json.field("interval", interval.total_seconds.to_i64)
json.field("till", till.try(&.to_unix)) if till
json.field("till", till.try(&.to_unix))
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/mel/task.cr
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ module Mel::Task
time = Time.unix(json["time"].as_i64)
retries = json["retries"].as_i
attempts = json["attempts"].as_i
till = json["till"]?.try { |timestamp| Time.unix(timestamp.as_i64) }
till = json["till"]?.try &.as_i64?.try { |timestamp| Time.unix(timestamp) }
schedule = json["schedule"]?.try(&.as_s)
interval = json["interval"]?.try(&.as_i64.seconds)

Expand Down

0 comments on commit 6cd0d42

Please sign in to comment.