./lib/rack/passbook.rb in rack-passbook-0.1.1 vs ./lib/rack/passbook.rb in rack-passbook-0.2.0

- old
+ new

@@ -7,23 +7,22 @@ require 'sequel' module Rack class Passbook < Sinatra::Base - VERSION = '0.1.1' use Rack::PostBodyContentTypeParser helpers Sinatra::Param - Sequel.extension :core_extensions, :migration, :pg_hstore, :pg_hstore_ops + autoload :Pass, 'rack/passbook/models/pass' + autoload :Registration, 'rack/passbook/models/registration' - autoload :Pass, ::File.join(::File.dirname(__FILE__), 'passbook/models/pass') - autoload :Registration, ::File.join(::File.dirname(__FILE__), 'passbook/models/registration') - disable :raise_errors, :show_exceptions configure do + Sequel.extension :core_extensions, :migration, :pg_hstore, :pg_hstore_ops + if ENV['DATABASE_URL'] DB = Sequel.connect(ENV['DATABASE_URL']) Sequel::Migrator.run(DB, ::File.join(::File.dirname(__FILE__), "passbook/migrations"), table: 'passbook_schema_info') end end @@ -51,10 +50,10 @@ # a given update tag (timestamp). get '/devices/:device_library_identifier/registrations/:pass_type_identifier/?' do @passes = Pass.filter(pass_type_identifier: params[:pass_type_identifier]).join(Registration.dataset, device_library_identifier: params[:device_library_identifier]) halt 404 if @passes.empty? - @passes = @passes.filter('passes.updated_at > ?', params[:passesUpdatedSince]) if params[:passesUpdatedSince] + @passes = @passes.filter("#{Pass.table_name}.updated_at > ?", Time.parse(params[:passesUpdatedSince])) if params[:passesUpdatedSince] if @passes.any? { lastUpdated: @passes.collect(&:updated_at).max, serialNumbers: @passes.collect(&:serial_number).collect(&:to_s)