Skip to content

Commit

Permalink
Merge pull request #1110 from transitland/master
Browse files Browse the repository at this point in the history
Production release 4.9.33
  • Loading branch information
irees committed Jun 20, 2017
2 parents 2095ff4 + 8372616 commit 2b53d26
Show file tree
Hide file tree
Showing 32 changed files with 1,049 additions and 695 deletions.
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,35 @@

## [Unreleased](https://github.com/transitland/transitland-datastore/tree/HEAD)

[Full Changelog](https://github.com/transitland/transitland-datastore/compare/4.9.31...HEAD)
[Full Changelog](https://github.com/transitland/transitland-datastore/compare/4.9.32...HEAD)

**Fixed bugs:**

- RSPs missing trips [\#1104](https://github.com/transitland/transitland-datastore/issues/1104)

**Closed issues:**

- Auto-enqueue improvements [\#1038](https://github.com/transitland/transitland-datastore/issues/1038)

**Merged pull requests:**

- Production release 4.9.32 [\#1102](https://github.com/transitland/transitland-datastore/pull/1102) ([irees](https://github.com/irees))

## [4.9.32](https://github.com/transitland/transitland-datastore/tree/4.9.32) (2017-06-01)
[Full Changelog](https://github.com/transitland/transitland-datastore/compare/4.9.31...4.9.32)

**Fixed bugs:**

- New GTFS Import: Do not lookup RSPs by EIFF [\#1105](https://github.com/transitland/transitland-datastore/issues/1105)
- SystemStackError: stack level too deep [\#1093](https://github.com/transitland/transitland-datastore/issues/1093)

**Merged pull requests:**

- RSP: Use EIFFs for trips [\#1109](https://github.com/transitland/transitland-datastore/pull/1109) ([irees](https://github.com/irees))
- updating gems & pegging `mail` gem to address security vulnerability [\#1108](https://github.com/transitland/transitland-datastore/pull/1108) ([drewda](https://github.com/drewda))
- RSPs for each Route [\#1106](https://github.com/transitland/transitland-datastore/pull/1106) ([irees](https://github.com/irees))
- Better recursive bounds [\#1101](https://github.com/transitland/transitland-datastore/pull/1101) ([doublestranded](https://github.com/doublestranded))
- FeedVersionInfo: Improved error handling [\#1100](https://github.com/transitland/transitland-datastore/pull/1100) ([irees](https://github.com/irees))
- Production release 4.9.31 [\#1086](https://github.com/transitland/transitland-datastore/pull/1086) ([irees](https://github.com/irees))

## [4.9.31](https://github.com/transitland/transitland-datastore/tree/4.9.31) (2017-05-23)
Expand Down
6 changes: 0 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,3 @@ gem 'unicorn', group: [:staging, :production]

# profiling
gem 'memory_profiler', group: [:test, :development]

# email
# temporarily pegging this version to address a security vulnerability
# https://github.com/mikel/mail/pull/1097
# TODO: remove once https://github.com/mikel/mail/issues/1116 is addressed
gem 'mail', '2.6.6.rc1'
31 changes: 15 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ GEM
rack-test (~> 0.6, >= 0.6.2)
rest-client (>= 1.7.3, < 3.0)
rspec (~> 3.1)
annotate (2.7.1)
annotate (2.7.2)
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 12.0)
rake (>= 10.4, < 13.0)
arel (6.0.4)
aws-sdk (2.9.27)
aws-sdk-resources (= 2.9.27)
aws-sdk-core (2.9.27)
aws-sdk (2.9.37)
aws-sdk-resources (= 2.9.37)
aws-sdk-core (2.9.37)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.9.27)
aws-sdk-core (= 2.9.27)
aws-sdk-resources (2.9.37)
aws-sdk-core (= 2.9.37)
aws-sigv4 (1.0.0)
bcrypt (3.1.11)
better_errors (2.1.1)
Expand Down Expand Up @@ -179,7 +179,7 @@ GEM
request_store
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.6.rc1)
mail (2.6.6)
mime-types (>= 1.16, < 4)
marginalia (1.4.0)
actionpack (>= 2.3)
Expand All @@ -189,14 +189,14 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
mini_portile2 (2.2.0)
minitest (5.10.2)
multi_json (1.12.1)
multipart-post (2.0.0)
netrc (0.11.0)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
oj (3.0.10)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
oj (3.1.0)
orm_adapter (0.5.0)
pg (0.20.0)
pghero (1.7.0)
Expand Down Expand Up @@ -255,7 +255,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.18.0)
rake (11.3.0)
rake (12.0.0)
rcsv (0.3.1)
redis (3.3.3)
redis-actionpack (5.0.1)
Expand Down Expand Up @@ -319,9 +319,9 @@ GEM
ruby-progressbar (1.8.1)
rubyzip (1.2.1)
safe_yaml (1.0.4)
sentry-raven (2.5.1)
sentry-raven (2.5.2)
faraday (>= 0.7.6, < 1.0)
sidekiq (5.0.0)
sidekiq (5.0.2)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
Expand Down Expand Up @@ -411,7 +411,6 @@ DEPENDENCIES
json-schema
jwt
logstasher
mail (= 2.6.6.rc1)
marginalia
memory_profiler
oj
Expand Down
18 changes: 18 additions & 0 deletions app/controllers/api/v1/activity_updates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,22 @@ def index
format.rss { render layout: false }
end
end

private

def query_params
{
feed: {
desc: "Filter by Feed",
type: "onestop_id",
array: true
},
changeset: {
desc: "Filter by Changeset ID",
type: "integer",
array: true
}
}
end

end
15 changes: 15 additions & 0 deletions app/controllers/api/v1/change_payloads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ def destroy

private

def query_params
{
ids: {
desc: "Change Payload ID",
type: "integer",
array: true
},
changeset_id: {
desc: "Changeset ID",
type: "integer",
show: false
}
}
end

def change_payload_params
params.require(:change_payload).permit!
end
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/api/v1/changesets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ def revert

private

def query_params
{
ids: {
desc: "Filter by Changeset ID",
type: "integer",
array: true
},
applied: {
desc: "Applied Changesets",
type: "boolean"
}
}
end

def set_changeset
@changeset = Changeset.find(params[:id])
end
Expand Down
193 changes: 193 additions & 0 deletions app/controllers/api/v1/current_entity_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
class Api::V1::CurrentEntityController < Api::V1::BaseApiController
include JsonCollectionPagination
include DownloadableCsv
include AllowFiltering

def self.model
fail Exception.new("Abstract method")
end

def index
index_query
index_includes
respond_to do |format|
format.json { render paginated_json_collection(@collection).merge({ scope: render_scope, each_serializer: render_serializer }) }
format.geojson { render paginated_geojson_collection(@collection).merge({ scope: render_scope }) }
format.csv { return_downloadable_csv(@collection, self.class.model.name.underscore.pluralize) }
end
end

def show
set_model
respond_to do |format|
format.json { render json: @model, serializer: render_serializer, scope: render_scope }
format.geojson { render json: @model, serializer: GeoJSONSerializer }
end
end

private

def index_query
# Entity
@collection = (self.class.model).where('')
@collection = AllowFiltering.by_onestop_id(@collection, params)
@collection = AllowFiltering.by_tag_keys_and_values(@collection, params)
@collection = AllowFiltering.by_updated_since(@collection, params)

# Geometry
index_query_geometry

# Imported From Feed
if params[:imported_from_feed].present?
@collection = @collection.where_imported_from_feed(Feed.find_by_onestop_id!(params[:imported_from_feed]))
end
if params[:imported_from_feed_version].present?
@collection = @collection.where_imported_from_feed_version(FeedVersion.find_by!(sha1: params[:imported_from_feed_version]))
end
if params[:imported_from_active_feed_version].presence.eql?("true")
@collection = @collection.where_imported_from_active_feed_version
end
if params[:imported_with_gtfs_id].present?
@collection = @collection.where_imported_with_gtfs_id(params[:gtfs_id] || params[:imported_with_gtfs_id])
end
if params[:import_level].present?
@collection = @collection.where_import_level(AllowFiltering.param_as_array(params, :import_level))
end
end

def index_query_geometry
if [params[:lat], params[:lon]].map(&:present?).all?
point = (self.class.model)::GEOFACTORY.point(params[:lon], params[:lat])
r = params[:r] || 100 # meters TODO: move this to a more logical place
@collection = @collection.where{st_dwithin(geometry, point, r)}.order{st_distance(geometry, point)}
end
if params[:bbox].present?
@collection = @collection.geometry_within_bbox(params[:bbox])
end
end

def index_includes
scope = render_scope
@collection = @collection.includes{[imported_from_feeds, imported_from_feed_versions]} if scope[:imported_from_Feeds]
@collection = @collection.includes(:issues) if scope[:issues]
end

def render_scope
# Get the list of include and exclude options
incl = {
geometry: true,
issues: false,
imported_from_feeds: false,
id: false
}
AllowFiltering.param_as_array(params, :include).map(&:to_sym).each { |i| incl[i] = true }
AllowFiltering.param_as_array(params, :exclude).map(&:to_sym).each { |i| incl[i] = false }
# Backwards compat
ii = AllowFiltering.to_boolean(params[:embed_issues])
incl[:issues] = ii if !ii.nil?
eg = AllowFiltering.to_boolean(params[:exclude_geometry])
ig = AllowFiltering.to_boolean(params[:include_geometry])
incl[:geometry] = true if (ig == true || eg == false)
incl[:geometry] = false if (ig == false || eg == true)
return incl
end

def render_serializer
ActiveModel::Serializer.serializer_for(self.class.model)
end

def set_model
@model = (self.class.model).find_by_onestop_id!(params[:id])
end

def query_params
# Allowed query parameters - and documentation
{
onestop_id: {
desc: "Onestop ID",
type: "onestop_id",
array: true
},
lat: {
desc: "Latitude",
type: "float"
},
lon: {
desc: "Longitude",
type: "float"
},
r: {
desc: "Radius, in meters",
type: "float"
},
bbox: {
desc: "Bounding box",
type: "bbox"
},
updated_since: {
desc: "Updated since",
type: "datetime"
},
import_level: {
desc: "Import level",
type: "integer",
array: true
},
imported_with_gtfs_id: {
desc: "Imported with GTFS ID",
type: "string",
array: true
},
gtfs_id: {
show: false
},
imported_from_feed: {
desc: "Imported from Feed",
type: "onestop_id",
array: true
},
imported_from_feed_version: {
desc: "Imported from Feed Version",
type: "sha1",
array: true
},
imported_from_active_feed_version: {
desc: "Imported from the current active Feed Version",
type: "boolean"
},
tag_key: {
desc: "Tag key",
type: "string"
},
tag_value: {
desc: "Tag value",
type: "string"
},
include: {
desc: "Include values",
type: "enum",
enum: ["geometry","imported_from_feeds","issues"]
},
exclude: {
desc: "Exclude values",
type: "enum",
enum: ["geometry","imported_from_feeds","issues"]
},
embed_issues: {
desc: "Embed Issues",
type: "boolean",
show: false
},
include_geometry: {
desc: "Include geometry",
type: "boolean",
show: false
},
exclude_geometry: {
desc: "Exclude geometry",
type: "boolean",
show: false
}
}
end
end
Loading

0 comments on commit 2b53d26

Please sign in to comment.