Allow requests from shortcuts
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
require "pry"
|
||||||
module Adamantium
|
module Adamantium
|
||||||
module Actions
|
module Actions
|
||||||
module Workouts
|
module Workouts
|
||||||
@@ -6,10 +7,17 @@ module Adamantium
|
|||||||
|
|
||||||
def handle(req, res)
|
def handle(req, res)
|
||||||
tempfile = Tempfile.new(%w/path .gpx/)
|
tempfile = Tempfile.new(%w/path .gpx/)
|
||||||
tempfile.write req.params[:file][:tempfile]
|
|
||||||
|
if req.params.to_h.dig(:file, :tempfile) != nil
|
||||||
|
tempfile.write req.params[:file][:tempfile].read
|
||||||
|
else
|
||||||
|
tempfile.write req.params[:file]
|
||||||
|
end
|
||||||
|
|
||||||
tempfile.rewind
|
tempfile.rewind
|
||||||
|
|
||||||
gpxfile = gpx_parser.call(file: tempfile)
|
|
||||||
|
gpxfile = gpx_parser.call(path: tempfile.path)
|
||||||
|
|
||||||
if gpxfile.success?
|
if gpxfile.success?
|
||||||
create.call(**gpxfile.value!)
|
create.call(**gpxfile.value!)
|
||||||
|
@@ -9,9 +9,9 @@ module Adamantium
|
|||||||
class GpxParser
|
class GpxParser
|
||||||
include Dry::Monads[:result]
|
include Dry::Monads[:result]
|
||||||
|
|
||||||
def call(file:)
|
def call(path:)
|
||||||
gpxfile = GeoRuby::Gpx4r::GpxFile.open(file.path)
|
gpxfile = GeoRuby::Gpx4r::GpxFile.open(path)
|
||||||
gpx = GPX::GPXFile.new(gpx_file: file.path)
|
gpx = GPX::GPXFile.new(gpx_file: path)
|
||||||
|
|
||||||
x = gpxfile.as_line_string.points.flat_map { |p| p.x }
|
x = gpxfile.as_line_string.points.flat_map { |p| p.x }
|
||||||
y = gpxfile.as_line_string.points.flat_map { |p| p.y }
|
y = gpxfile.as_line_string.points.flat_map { |p| p.y }
|
||||||
|
Reference in New Issue
Block a user