Add workouts

This commit is contained in:
2023-04-25 15:56:41 +10:00
parent 971e0007dd
commit c89b5b0998
13 changed files with 197 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
module Adamantium
module Actions
module Workouts
class Create < Action
include Deps["geo.gpx_parser", "commands.workouts.create"]
def handle(req, res)
tempfile = Tempfile.new(%w/path .gpx/)
tempfile.write req.params[:file]
tempfile.rewind
gpxfile = gpx_parser.call(file: tempfile)
if gpxfile.success?
create.call(**gpxfile.value!)
res.status = 201
else
res.status = 500
end
ensure
tempfile.close
tempfile.unlink
end
end
end
end
end

View File

@@ -0,0 +1,13 @@
module Adamantium
module Actions
module Workouts
class Index < Action
include Deps["views.workouts.index"]
def handle(req, res)
res.render index
end
end
end
end
end