Start of web app

This commit is contained in:
2019-11-07 22:37:49 +03:00
parent fcfc200410
commit 483f6c8bd6
8 changed files with 73 additions and 21 deletions

View File

@ -24,10 +24,11 @@ post "/api/finish" do |env|
env.response.status_code = 204
end
get "/api/remaining-time" do |env|
get "/api/status" do |env|
profile = app.profile Dayoff::ProfileId.new(env.get("profile_id").to_s)
rem_span = profile.remaining_time now
data = {
started: profile.started?,
hours: rem_span.total_hours.to_i32,
minutes: rem_span.minutes.to_i32,
}
@ -35,4 +36,8 @@ get "/api/remaining-time" do |env|
data.to_json
end
get "/" do
render "public/index.ecr"
end
Kemal.run

View File

@ -34,8 +34,12 @@ module Dayoff
end
end
def started? : Bool
!started_point.nil?
end
def start(time : Time) : Nil
if started_point
if started?
raise AlreadyStarted.new
end
@wrecords.each do |wr|