Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production release 4.9.35 #1117

Merged
merged 21 commits into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

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

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

**Merged pull requests:**

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

## [4.9.34](https://github.com/transitland/transitland-datastore/tree/4.9.34) (2017-06-22)
[Full Changelog](https://github.com/transitland/transitland-datastore/compare/4.9.33...4.9.34)

**Fixed bugs:**

- Stop becomes StopPlatform [\#1103](https://github.com/transitland/transitland-datastore/issues/1103)
- Slow StopsController include query [\#996](https://github.com/transitland/transitland-datastore/issues/996)

**Merged pull requests:**

- Check if Stop is a Stop or StopPlatform [\#1115](https://github.com/transitland/transitland-datastore/pull/1115) ([irees](https://github.com/irees))
- Production release 4.9.33 [\#1110](https://github.com/transitland/transitland-datastore/pull/1110) ([irees](https://github.com/irees))

## [4.9.33](https://github.com/transitland/transitland-datastore/tree/4.9.33) (2017-06-19)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'rails', '4.2.8'
gem 'rails', '4.2.9'

# Transitland Datastore components
path 'components' do
Expand Down
88 changes: 44 additions & 44 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.8)
actionpack (= 4.2.8)
actionview (= 4.2.8)
activejob (= 4.2.8)
actionmailer (4.2.9)
actionpack (= 4.2.9)
actionview (= 4.2.9)
activejob (= 4.2.9)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.8)
actionview (= 4.2.8)
activesupport (= 4.2.8)
actionpack (4.2.9)
actionview (= 4.2.9)
activesupport (= 4.2.9)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.8)
activesupport (= 4.2.8)
actionview (4.2.9)
activesupport (= 4.2.9)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
Expand All @@ -45,22 +45,22 @@ GEM
active_record_doctor (1.3.1)
activerecord (>= 4.2)
railties (>= 4.2)
activejob (4.2.8)
activesupport (= 4.2.8)
activejob (4.2.9)
activesupport (= 4.2.9)
globalid (>= 0.3.0)
activemodel (4.2.8)
activesupport (= 4.2.8)
activemodel (4.2.9)
activesupport (= 4.2.9)
builder (~> 3.1)
activerecord (4.2.8)
activemodel (= 4.2.8)
activesupport (= 4.2.8)
activerecord (4.2.9)
activemodel (= 4.2.9)
activesupport (= 4.2.9)
arel (~> 6.0)
activerecord-import (0.18.3)
activerecord-import (0.19.0)
activerecord (>= 3.2)
activerecord-postgis-adapter (3.1.5)
activerecord (~> 4.2)
rgeo-activerecord (>= 4.0.4)
activesupport (4.2.8)
activesupport (4.2.9)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
Expand All @@ -77,13 +77,13 @@ GEM
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 13.0)
arel (6.0.4)
aws-sdk (2.9.37)
aws-sdk-resources (= 2.9.37)
aws-sdk-core (2.9.37)
aws-sdk (2.10.3)
aws-sdk-resources (= 2.10.3)
aws-sdk-core (2.10.3)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.9.37)
aws-sdk-core (= 2.9.37)
aws-sdk-resources (2.10.3)
aws-sdk-core (= 2.10.3)
aws-sigv4 (1.0.0)
bcrypt (3.1.11)
better_errors (2.1.1)
Expand Down Expand Up @@ -128,7 +128,7 @@ GEM
enumerize (2.1.2)
activesupport (>= 3.2)
erubis (2.7.0)
excon (0.56.0)
excon (0.57.0)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.8.0)
Expand All @@ -139,7 +139,7 @@ GEM
ffaker (2.5.0)
figaro (1.1.1)
thor (~> 0.14)
fog-aws (1.3.0)
fog-aws (1.4.0)
fog-core (~> 1.38)
fog-json (~> 1.0)
fog-xml (~> 0.1)
Expand Down Expand Up @@ -196,9 +196,9 @@ GEM
netrc (0.11.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
oj (3.1.0)
oj (3.2.0)
orm_adapter (0.5.0)
pg (0.20.0)
pg (0.21.0)
pghero (1.7.0)
activerecord
polyamorous (1.1.0)
Expand All @@ -225,16 +225,16 @@ GEM
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.8)
actionmailer (= 4.2.8)
actionpack (= 4.2.8)
actionview (= 4.2.8)
activejob (= 4.2.8)
activemodel (= 4.2.8)
activerecord (= 4.2.8)
activesupport (= 4.2.8)
rails (4.2.9)
actionmailer (= 4.2.9)
actionpack (= 4.2.9)
actionview (= 4.2.9)
activejob (= 4.2.9)
activemodel (= 4.2.9)
activerecord (= 4.2.9)
activesupport (= 4.2.9)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.8)
railties (= 4.2.9)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
Expand All @@ -249,9 +249,9 @@ GEM
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.8)
actionpack (= 4.2.8)
activesupport (= 4.2.8)
railties (4.2.9)
actionpack (= 4.2.9)
activesupport (= 4.2.9)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.18.0)
Expand Down Expand Up @@ -308,7 +308,7 @@ GEM
rspec-expectations (~> 3.6.0)
rspec-mocks (~> 3.6.0)
rspec-support (~> 3.6.0)
rspec-sidekiq (3.0.1)
rspec-sidekiq (3.0.3)
rspec-core (~> 3.0, >= 3.0.0)
sidekiq (>= 2.4.0)
rspec-support (3.6.0)
Expand All @@ -319,9 +319,9 @@ GEM
ruby-progressbar (1.8.1)
rubyzip (1.2.1)
safe_yaml (1.0.4)
sentry-raven (2.5.2)
sentry-raven (2.5.3)
faraday (>= 0.7.6, < 1.0)
sidekiq (5.0.2)
sidekiq (5.0.3)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
Expand Down Expand Up @@ -358,7 +358,7 @@ GEM
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.7)
timecop (0.8.1)
timecop (0.9.0)
tzinfo (1.2.3)
thread_safe (~> 0.1)
unf (0.1.4)
Expand Down Expand Up @@ -421,7 +421,7 @@ DEPENDENCIES
pry-rescue
pry-stack_explorer
rack-cors
rails (= 4.2.8)
rails (= 4.2.9)
rails-erd
redis
redis-actionpack
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/api/v1/stop_stations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def index_query
if params[:wheelchair_boarding].present?
@collection = @collection.where(wheelchair_boarding: AllowFiltering.to_boolean(params[:wheelchair_boarding] ))
end
if params[:min_platforms].present?
@collection = @collection.with_min_platforms(params[:min_platforms].to_i)
end
end

def index_includes
Expand Down Expand Up @@ -92,6 +95,10 @@ def query_params
wheelchair_boarding: {
desc: "Wheelchair boarding",
type: "boolean"
},
min_platforms: {
desc: "Mininum number of platforms",
type: "integer"
}
})
end
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/concerns/json_collection_pagination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def paginated_collection(collection)
end

if include_total
meta[:total] = collection.count
total = collection.count
(total = total.size) if total.is_a?(Hash)
meta[:total] = total
end
# Return results + meta
data_on_page = data_on_page.empty? ? collection.model.none : data_on_page
Expand Down
8 changes: 0 additions & 8 deletions app/models/concerns/from_gtfs.rb

This file was deleted.

32 changes: 0 additions & 32 deletions app/models/feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,38 +259,6 @@ def import_status
end
end

##### FromGTFS ####
include FromGTFS
def self.from_gtfs(entity, attrs={})
# Entity is a feed.
visited_stops = Set.new
entity.agencies.each { |agency| visited_stops |= agency.stops }
coordinates = Stop::GEOFACTORY.collection(
visited_stops.map { |stop| Stop::GEOFACTORY.point(*stop.coordinates) }
)
geohash = GeohashHelpers.fit(coordinates)
geometry = RGeo::Cartesian::BoundingBox.create_from_geometry(coordinates)
# Generate third Onestop ID component
feed_id = nil
if entity.file_present?('feed_info.txt')
feed_info = entity.feed_infos.first
feed_id = feed_info.feed_id if feed_info
end
name_agencies = entity.agencies.select { |agency| agency.stops.size > 0 }.map(&:agency_name).join('~')
name_url = Addressable::URI.parse(attrs[:url]).host.gsub(/[^a-zA-Z0-9]/, '') if attrs[:url]
name = feed_id.presence || name_agencies.presence || name_url.presence || 'unknown'
# Create Feed
attrs[:geometry] = geometry.to_geometry
attrs[:onestop_id] = OnestopId.handler_by_model(self).new(
geohash: geohash,
name: name
)
feed = Feed.new(attrs)
feed.tags ||= {}
feed.tags[:feed_id] = feed_id if feed_id
feed
end

private

def set_default_values
Expand Down
10 changes: 4 additions & 6 deletions app/models/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ class Issue < ActiveRecord::Base

scope :with_type, -> (search_string) { where(issue_type: search_string.split(',')) }
scope :from_feed, -> (feed_onestop_id) {
where("issues.id IN (SELECT entities_with_issues.issue_id FROM entities_with_issues INNER JOIN
entities_imported_from_feed ON entities_with_issues.entity_id=entities_imported_from_feed.entity_id
AND entities_with_issues.entity_type=entities_imported_from_feed.entity_type WHERE entities_imported_from_feed.feed_id=?)
OR issues.id in (SELECT issues.id FROM issues INNER JOIN changesets ON
issues.created_by_changeset_id=changesets.id WHERE changesets.feed_id=?)",
Feed.find_by_onestop_id!(feed_onestop_id), Feed.find_by_onestop_id!(feed_onestop_id))
joins("INNER JOIN entities_with_issues ON entities_with_issues.issue_id = issues.id")
.joins("INNER JOIN entities_imported_from_feed ON entities_imported_from_feed.entity_id = entities_with_issues.entity_id AND entities_imported_from_feed.entity_type = entities_with_issues.entity_type")
.where("entities_imported_from_feed.feed_id = ?", Feed.find_by_onestop_id!(feed_onestop_id).id)
.distinct
}

CATEGORIES = {
Expand Down
32 changes: 0 additions & 32 deletions app/models/operator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,38 +125,6 @@ def recompute_convex_hull_around_stops
Operator.convex_hull(self.stops, projected: false)
end

##### FromGTFS ####
include FromGTFS
def self.from_gtfs(entity, attrs={})
# GTFS Constructor
# Convert to TL Stops so geometry projection works properly...
tl_stops = entity.stops.map { |stop| Stop.new(geometry: Stop::GEOFACTORY.point(*stop.coordinates)) }
geohash = GeohashHelpers.fit(
Stop::GEOFACTORY.collection(tl_stops.map { |stop| stop[:geometry] })
)
# Generate third Onestop ID component
name = [entity.agency_name, entity.id, "unknown"]
.select(&:present?)
.first
# Create Operator
attrs[:geometry] = Operator.convex_hull(tl_stops, projected: false)
attrs[:name] = name
attrs[:onestop_id] = OnestopId.handler_by_model(self).new(
geohash: geohash,
name: name
)
operator = Operator.new(attrs)
operator.tags ||= {}
operator.tags[:agency_phone] = entity.agency_phone
operator.tags[:agency_lang] = entity.agency_lang
operator.tags[:agency_fare_url] = entity.agency_fare_url
operator.tags[:agency_id] = entity.id
operator.tags[:agency_email] = entity.agency_email
operator.timezone = entity.agency_timezone
operator.website = entity.agency_url
operator
end

private

def set_default_values
Expand Down
31 changes: 0 additions & 31 deletions app/models/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,37 +239,6 @@ def generate_onestop_id
)
onestop_id.to_s
end

include FromGTFS
def self.from_gtfs(entity, attrs={})
# GTFS Constructor
coordinates = Stop::GEOFACTORY.collection(
entity.stops.map { |stop| Stop::GEOFACTORY.point(*stop.coordinates) }
)
geohash = GeohashHelpers.fit(coordinates)
name = [entity.route_short_name, entity.route_long_name, entity.id, "unknown"]
.select(&:present?)
.first
onestop_id = OnestopId.handler_by_model(self).new(
geohash: geohash,
name: name
)
route = Route.new(
name: name,
onestop_id: onestop_id.to_s,
vehicle_type: entity.route_type.to_i
)
route.color = Route.color_from_gtfs(entity.route_color)
# Copy over GTFS attributes to tags
route.tags ||= {}
route.tags[:route_long_name] = entity.route_long_name
route.tags[:route_desc] = entity.route_desc
route.tags[:route_url] = entity.route_url
route.tags[:route_color] = entity.route_color
route.tags[:route_text_color] = entity.route_text_color
route
end

end

class OldRoute < BaseRoute
Expand Down
Loading