From 22f02e09f17f94d3599ab4042702e779a8b495a8 Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sun, 30 Jun 2013 21:56:49 -0500 Subject: [PATCH 01/19] Edit existing and add new migrations --- db/migrate/20130615194944_create_setlists.rb | 6 ++++-- db/migrate/20130617184735_create_concerts.rb | 5 +++-- db/migrate/20130630155649_create_songs.rb | 10 ++++++++++ db/schema.rb | 21 ++++++++++++++------ 4 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20130630155649_create_songs.rb diff --git a/db/migrate/20130615194944_create_setlists.rb b/db/migrate/20130615194944_create_setlists.rb index 0a1f270..364d19b 100644 --- a/db/migrate/20130615194944_create_setlists.rb +++ b/db/migrate/20130615194944_create_setlists.rb @@ -1,8 +1,10 @@ class CreateSetlists < ActiveRecord::Migration def change create_table :setlists do |t| - t.text :showdate - t.text :deadset + t.integer :concert_id + t.integer :song_id + t.integer :order + t.string :group t.timestamps end diff --git a/db/migrate/20130617184735_create_concerts.rb b/db/migrate/20130617184735_create_concerts.rb index ef38c00..7bee2bd 100644 --- a/db/migrate/20130617184735_create_concerts.rb +++ b/db/migrate/20130617184735_create_concerts.rb @@ -1,8 +1,9 @@ class CreateConcerts < ActiveRecord::Migration def change create_table :concerts do |t| - t.string :date - t.text :details + t.date :date + t.text :venue + t.text :tour t.timestamps end diff --git a/db/migrate/20130630155649_create_songs.rb b/db/migrate/20130630155649_create_songs.rb new file mode 100644 index 0000000..35f0f7a --- /dev/null +++ b/db/migrate/20130630155649_create_songs.rb @@ -0,0 +1,10 @@ +class CreateSongs < ActiveRecord::Migration + def change + create_table :songs do |t| + t.string :title + t.string :media_link + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8407f06..4070c5f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,11 +11,12 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130623202033) do +ActiveRecord::Schema.define(:version => 20130630155649) do create_table "concerts", :force => true do |t| - t.string "date" - t.text "details" + t.date "date" + t.text "venue" + t.text "tour" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end @@ -28,8 +29,17 @@ end create_table "setlists", :force => true do |t| - t.text "showdate" - t.text "deadset" + t.integer "concert_id" + t.integer "song_id" + t.integer "order" + t.string "group" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "songs", :force => true do |t| + t.string "title" + t.string "media_link" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end @@ -47,7 +57,6 @@ t.string "last_sign_in_ip" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.string "username" end add_index "users", ["email"], :name => "index_users_on_email", :unique => true From 3ad24c23d33558f7d5485a007998d0f206d3abaf Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sun, 30 Jun 2013 21:58:54 -0500 Subject: [PATCH 02/19] New rake task to grab data and save in db --- lib/tasks/scrape_setlists.rake | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/tasks/scrape_setlists.rake diff --git a/lib/tasks/scrape_setlists.rake b/lib/tasks/scrape_setlists.rake new file mode 100644 index 0000000..5ccbc17 --- /dev/null +++ b/lib/tasks/scrape_setlists.rake @@ -0,0 +1,39 @@ +desc 'Scrape grateful dead setlists from setlist.fm' +task :gd => :environment do + require 'nokogiri' + require 'open-uri' + @links_count = 0 + range = (1..196).to_a + range.each do |i| + page = Nokogiri::HTML(open("http://www.setlist.fm/setlists/grateful-dead-bd6ad4a.html?page=#{i}")) + # Nokogiri supports CSS-style selectors + @links = [] + page.search('#id1d h2 a').each { |a| @links << a['href'] } + @links.each do |url| + url = url[1..-1] + url = url[1..-1] + concert_page = Nokogiri::HTML(open("http://www.setlist.fm#{url}")) + @date = concert_page.css(".dateBlock").text.delete("\n") + header = [] + concert_page.css(".eventBlock .value").each do |e| + header << e.text + end + @concert = Concert.create(date: @date, venue: header[1], tour: header[2]) + i = 1 + concert_page.css("ol li").each do |l| + if l.text.delete("\n").match("Set") || l.text.delete("\n").match("Encore") + @group = l.text.delete("\n") + else + if l.children.children.children[0].present? + title = l.children.children.children[0].text + else + title = "blank" + end + song = Song.where(title: title).first_or_create + Setlist.create(song_id: song.id, order: i, concert_id: @concert.id, group: @group) + i += 1 + end + end + end + end +end \ No newline at end of file From 87b591b6717f56119d52149c310c4a2df66165e3 Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sun, 30 Jun 2013 21:59:39 -0500 Subject: [PATCH 03/19] Added some new gems; pry, simple_form, decent_exposure --- Gemfile | 3 +++ Gemfile.lock | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Gemfile b/Gemfile index b968d71..43532bc 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,8 @@ gem 'rails', '3.2.13' gem 'pg' gem 'devise' gem 'nokogiri' +gem "decent_exposure", "~> 2.2.0" +gem 'simple_form' # Gems used only for assets and not required # in production environments by default. @@ -25,6 +27,7 @@ group :test do gem 'cucumber-rails' gem 'database_cleaner' gem 'rspec-rails' + gem 'pry' end gem 'jquery-rails' diff --git a/Gemfile.lock b/Gemfile.lock index e6dd03b..2851926 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -56,6 +56,7 @@ GEM nokogiri (>= 1.5.0) rails (~> 3.0) database_cleaner (1.0.1) + decent_exposure (2.2.0) devise (2.2.4) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) @@ -133,6 +134,9 @@ GEM railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) + simple_form (2.1.0) + actionpack (~> 3.0) + activemodel (~> 3.0) slop (3.4.5) sprockets (2.2.2) hike (~> 1.2) @@ -160,12 +164,15 @@ DEPENDENCIES coffee-rails (~> 3.2.1) cucumber-rails database_cleaner + decent_exposure (~> 2.2.0) devise jquery-rails nokogiri pg + pry pry-rails rails (= 3.2.13) rspec-rails sass-rails (~> 3.2.3) + simple_form uglifier (>= 1.0.3) From abf0f2a3a98437d174137774c9de13007e0d3c95 Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sun, 30 Jun 2013 22:05:05 -0500 Subject: [PATCH 04/19] Added new route, model and controller for song; modified existing models and associations --- app/controllers/songs_controller.rb | 11 +++++++++++ app/models/concert.rb | 6 ++++-- app/models/setlist.rb | 4 +++- app/models/song.rb | 5 +++++ config/routes.rb | 3 +++ 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 app/controllers/songs_controller.rb create mode 100644 app/models/song.rb diff --git a/app/controllers/songs_controller.rb b/app/controllers/songs_controller.rb new file mode 100644 index 0000000..ee5f2bc --- /dev/null +++ b/app/controllers/songs_controller.rb @@ -0,0 +1,11 @@ +class SongsController < ApplicationController + def new + @song = Song.new + end + + def create + @song.save! + end + +end + diff --git a/app/models/concert.rb b/app/models/concert.rb index a5bd025..496adb7 100644 --- a/app/models/concert.rb +++ b/app/models/concert.rb @@ -1,9 +1,11 @@ class Concert < ActiveRecord::Base - attr_accessible :date, :details + attr_accessible :date, :venue, :tour + has_many :setlists + has_many :songs, through: :setlists has_many :users, through: :favorites has_many :favorites - def self.search(search) + def self.search_by_date(search) if search search_split = search.split("-") search_split.each do |search| diff --git a/app/models/setlist.rb b/app/models/setlist.rb index a21db01..88fe3f6 100644 --- a/app/models/setlist.rb +++ b/app/models/setlist.rb @@ -1,3 +1,5 @@ class Setlist < ActiveRecord::Base - attr_accessible :showdate, :deadset + attr_accessible :concert_id, :song_id, :order, :group + belongs_to :concert + belongs_to :song end diff --git a/app/models/song.rb b/app/models/song.rb new file mode 100644 index 0000000..e6786aa --- /dev/null +++ b/app/models/song.rb @@ -0,0 +1,5 @@ +class Song < ActiveRecord::Base + attr_accessible :title, :media_link + has_many :setlists + +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 807cf1e..35f66f3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,9 @@ devise_for :users resources :concerts + resources :concert_sets + resources :setlists + resources :songs resources :favorites root :to => "concerts#index" From 803c382118095605a5dd0c664a8e9d094706e1c0 Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sun, 30 Jun 2013 22:06:22 -0500 Subject: [PATCH 05/19] Styled and changed markup for song lists --- app/assets/stylesheets/application.css | 11 +++++++++++ app/views/concerts/index.html.erb | 17 ++++++++++++++--- app/views/favorites/index.html.erb | 8 ++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f94f80c..e54f945 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -57,6 +57,17 @@ p { color: white; } +ul { + list-style-type: none; +} + +li { + font-family: 'RobotoThin', sans-serif; + font-size: 14px; + line-height: 20px; + color: white; +} + a { font-family: 'RobotoThin', sans-serif; font-size: 12px; diff --git a/app/views/concerts/index.html.erb b/app/views/concerts/index.html.erb index 0329dc2..defa6d9 100644 --- a/app/views/concerts/index.html.erb +++ b/app/views/concerts/index.html.erb @@ -5,13 +5,24 @@ <% end %> -
u +
+

<%= @search_term %> - <%= @concerts.count %>

<% if (@concerts) %> <% @concerts.each do |concert| %>

- <%= simple_format(concert.details) %> + <%= concert.date.strftime("%m/%d/%Y") %>

- +

+ <%= concert.venue %> +

+

+ <%= concert.tour %> +

+
    + <% concert.songs.each do |song| %> +
  • <%= song.title %>
  • li> + <% end %> +
<% if user_signed_in? %> <%= form_for concert.favorites.new do |f| %> <%= f.label :favorite, :class=>"hidden_label" %> diff --git a/app/views/favorites/index.html.erb b/app/views/favorites/index.html.erb index afedeb8..db27646 100644 --- a/app/views/favorites/index.html.erb +++ b/app/views/favorites/index.html.erb @@ -13,10 +13,14 @@

Favorite Concerts

<% @favorites.each do |favorite| %>

- <%= link_to favorite.concert.details[/.*/].chomp, "#", :class=>"setlist_button" %> + <%= link_to "#{favorite.concert.date} - #{favorite.concert.venue} - #{favorite.concert.tour}", "#", :class=>"setlist_button" %>

- <%= simple_format favorite.setlist %> +
    + <% favorite.concert.songs.each do |song| %> +
  • <%= song.title %>
  • + <% end %> +
<%= button_to "Delete", favorite, :method=>:delete, :class=>"deletebutton" %> <% end %> From 670661ad8434992baa81df50384f4de469f4e40d Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sun, 30 Jun 2013 22:06:49 -0500 Subject: [PATCH 06/19] Added search by venue and tour --- app/controllers/concerts_controller.rb | 23 ++++++++++++++----- app/models/concert.rb | 31 +++++++++++++++++++++++++- app/views/layouts/application.html.erb | 19 ++++++++++++++-- 3 files changed, 64 insertions(+), 9 deletions(-) diff --git a/app/controllers/concerts_controller.rb b/app/controllers/concerts_controller.rb index 6d65219..f8007f9 100644 --- a/app/controllers/concerts_controller.rb +++ b/app/controllers/concerts_controller.rb @@ -1,13 +1,24 @@ class ConcertsController < ApplicationController def index - @concerts = Concert.search(params[:search]) - if params[:search] - - if @concerts.blank? - flash[:notice] = "Sorry, there's no concert for this date" - end + if params[:search_by_date] + @concerts = Concert.search_by_date(params[:search_by_date]) + @search_term = params[:search_by_date] + elsif params[:search_by_venue] + @concerts = Concert.search_by_venue(params[:search_by_venue]) + @search_term = params[:search_by_venue] + elsif params[:search_by_tour] + @concerts = Concert.search_by_tour(params[:search_by_tour]) + @search_term = params[:search_by_tour] end + @shows = Concert.all + + @venues = @shows.uniq {|c| c.venue } + @tours = @shows.uniq {|c| c.tour } + + if @concerts.blank? + flash[:notice] = "Sorry, there's no concert for this date" + end end diff --git a/app/models/concert.rb b/app/models/concert.rb index 496adb7..b0c6b09 100644 --- a/app/models/concert.rb +++ b/app/models/concert.rb @@ -14,10 +14,39 @@ def self.search_by_date(search) end end search = search_split.join("-").to_s - where(:date => search).all + where(date: search).all else [] end end + def self.search_by_venue(search) + if search + search_split = search.split("-") + search_split.each do |search| + if search.starts_with? "0" + search.slice!(0) + end + end + search = search_split.join("-").to_s + where(venue: search).all + else + [] + end + end + + def self.search_by_tour(search) + if search + search_split = search.split("-") + search_split.each do |search| + if search.starts_with? "0" + search.slice!(0) + end + end + search = search_split.join("-").to_s + where(tour: search).all + else + [] + end + end end \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c743347..1338498 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -33,12 +33,27 @@ <% unless a_devise_page? %>
-

Search for a Grateful Dead
concert date in mm-dd-yy format

+

Search by Date

<%= form_tag concerts_path, :method => 'get' do %> - <%= text_field_tag :search, params[:search] %> + <%= text_field_tag :search_by_date, params[:search_by_date] %> <%= submit_tag "Search", :class => "searchbutton", :name => nil %> <% end %>
+
+

Search by Venue

+ <%= form_tag concerts_path, :method => 'get' do %> + <%= select_tag :search_by_venue, options_from_collection_for_select(@venues, "venue", "venue"), prompt: "Select something" %> + <%= submit_tag "Search", :class => "searchbutton", :name => nil %> + <% end %> +
+
+

Search by Tour

+ <%= form_tag concerts_path, :method => 'get' do %> + <%= select_tag :search_by_tour, options_from_collection_for_select(@tours, "tour", "tour"), prompt: "Select something" %> + <%= submit_tag "Search", :class => "searchbutton", :name => nil %> + <% end %> +
+
<% end %> From 72a168333b40c3cf338f11aa3dae776accedc3fe Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sun, 30 Jun 2013 22:29:01 -0500 Subject: [PATCH 07/19] Reused toggle code from favorites view for broader search results --- app/controllers/concerts_controller.rb | 4 +-- app/views/concerts/index.html.erb | 38 ++++++++++++-------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/app/controllers/concerts_controller.rb b/app/controllers/concerts_controller.rb index f8007f9..8320c9e 100644 --- a/app/controllers/concerts_controller.rb +++ b/app/controllers/concerts_controller.rb @@ -14,10 +14,10 @@ def index @shows = Concert.all @venues = @shows.uniq {|c| c.venue } - @tours = @shows.uniq {|c| c.tour } + @tours = @shows.uniq {|c| c.tour unless c.blank? } if @concerts.blank? - flash[:notice] = "Sorry, there's no concert for this date" + flash[:notice] = "Sorry there is no match for your search criteria" end end diff --git a/app/views/concerts/index.html.erb b/app/views/concerts/index.html.erb index defa6d9..3ab2a5e 100644 --- a/app/views/concerts/index.html.erb +++ b/app/views/concerts/index.html.erb @@ -6,32 +6,28 @@ <% end %>
-

<%= @search_term %> - <%= @concerts.count %>

- <% if (@concerts) %> - <% @concerts.each do |concert| %> -

- <%= concert.date.strftime("%m/%d/%Y") %> -

-

- <%= concert.venue %> -

-

- <%= concert.tour %> -

-
    + <%- if @concerts.present? %> +

    <%= @search_term %> - <%= @concerts.count %>

    + <% @concerts.each do |concert| %> +

    + <%= link_to "#{concert.date.strftime('%m/%d/%Y')} - #{concert.venue}", "#", :class=>"setlist_button" %> +

    +
    +
      <% concert.songs.each do |song| %> -
    1. <%= song.title %>
    2. li> - <% end %> -
- <% if user_signed_in? %> - <%= form_for concert.favorites.new do |f| %> - <%= f.label :favorite, :class=>"hidden_label" %> - <%= f.hidden_field(:concert_id) %> - <%= f.submit %> +
  • <%= song.title %>
  • <% end %> + +
    + <% if user_signed_in? %> + <%= form_for concert.favorites.new do |f| %> + <%= f.label :favorite, :class=>"hidden_label" %> + <%= f.hidden_field(:concert_id) %> + <%= f.submit %> <% end %> <% end %> <% end %> + <% end %>
    From 8cd3da1f4f7c4a8e5eb8cd3ddea07692f17ad6a6 Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sun, 30 Jun 2013 22:45:18 -0500 Subject: [PATCH 08/19] Notes about range and range set to 10 --- lib/tasks/scrape_setlists.rake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tasks/scrape_setlists.rake b/lib/tasks/scrape_setlists.rake index 5ccbc17..6cf77e2 100644 --- a/lib/tasks/scrape_setlists.rake +++ b/lib/tasks/scrape_setlists.rake @@ -3,7 +3,8 @@ task :gd => :environment do require 'nokogiri' require 'open-uri' @links_count = 0 - range = (1..196).to_a + # This range can be set up to 196. It must be set at 196 to retrieve all 1955 concerts. + range = (1..1).to_a range.each do |i| page = Nokogiri::HTML(open("http://www.setlist.fm/setlists/grateful-dead-bd6ad4a.html?page=#{i}")) # Nokogiri supports CSS-style selectors @@ -36,4 +37,5 @@ task :gd => :environment do end end end + puts "The database was seeded with #{@links.count} concerts and their songs." end \ No newline at end of file From b05bb639f8b11ddded182cf3332d23f2c754ddc9 Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Thu, 4 Jul 2013 00:58:28 -0500 Subject: [PATCH 09/19] Added some stats for songs and home page toady in history --- app/controllers/concerts_controller.rb | 37 +++++++++++++++----------- app/controllers/songs_controller.rb | 2 ++ app/helpers/concerts_helper.rb | 25 ++++++++++++++++- app/models/concert.rb | 3 +++ app/models/song.rb | 19 +++++++++++++ app/views/concerts/index.html.erb | 36 +++++++++++++------------ app/views/concerts/songs/show.html.erb | 1 + app/views/layouts/application.html.erb | 4 +-- app/views/songs/show.html.erb | 7 +++++ config/routes.rb | 2 +- 10 files changed, 100 insertions(+), 36 deletions(-) create mode 100644 app/views/concerts/songs/show.html.erb create mode 100644 app/views/songs/show.html.erb diff --git a/app/controllers/concerts_controller.rb b/app/controllers/concerts_controller.rb index 8320c9e..4bfc192 100644 --- a/app/controllers/concerts_controller.rb +++ b/app/controllers/concerts_controller.rb @@ -1,27 +1,34 @@ class ConcertsController < ApplicationController - - def index - if params[:search_by_date] - @concerts = Concert.search_by_date(params[:search_by_date]) - @search_term = params[:search_by_date] + expose(:concerts) do + if params[:search_by_date] + Concert.search_by_date(params[:search_by_date]) elsif params[:search_by_venue] - @concerts = Concert.search_by_venue(params[:search_by_venue]) - @search_term = params[:search_by_venue] + Concert.search_by_venue(params[:search_by_venue]) elsif params[:search_by_tour] - @concerts = Concert.search_by_tour(params[:search_by_tour]) - @search_term = params[:search_by_tour] + Concert.search_by_tour(params[:search_by_tour]) + else + concerts = todays_concerts end - @shows = Concert.all + end - @venues = @shows.uniq {|c| c.venue } - @tours = @shows.uniq {|c| c.tour unless c.blank? } + expose(:concerts_count) { concerts.count } - if @concerts.blank? - flash[:notice] = "Sorry there is no match for your search criteria" + def index + if concerts.blank? + flash[:notice] = "Please try again" + end end - end + def todays_concerts + concert_collection = Concert.all + concert_collection.collect! do |concert| + if concert.date.strftime('%m/%d') == Time.now.strftime('%m/%d') + concert + end + end + concert_collection.reject! { |c| c.nil? } + end end diff --git a/app/controllers/songs_controller.rb b/app/controllers/songs_controller.rb index ee5f2bc..d8a95fb 100644 --- a/app/controllers/songs_controller.rb +++ b/app/controllers/songs_controller.rb @@ -1,4 +1,6 @@ class SongsController < ApplicationController + expose(:song) { Song.find(params[:id]) } + def new @song = Song.new end diff --git a/app/helpers/concerts_helper.rb b/app/helpers/concerts_helper.rb index 516b508..ac958f3 100644 --- a/app/helpers/concerts_helper.rb +++ b/app/helpers/concerts_helper.rb @@ -1,2 +1,25 @@ module ConcertsHelper -end + + def venue_options + concerts = Concert.all.map { |c| c } + concerts.uniq! { |c| c.venue } + concerts.sort_by { |c| c.venue } + end + + def tour_options + concerts = Concert.all.map { |c| c } + concerts.uniq! { |c| c.tour } + end + + def search_criteria + if params[:search_by_date] + params[:search_by_date] + elsif params[:search_by_venue] + params[:search_by_venue] + elsif params[:search_by_tour] + params[:search_by_tour] + else + "Today in Grateful Dead history" + end + end +end \ No newline at end of file diff --git a/app/models/concert.rb b/app/models/concert.rb index b0c6b09..9f29d5a 100644 --- a/app/models/concert.rb +++ b/app/models/concert.rb @@ -17,6 +17,7 @@ def self.search_by_date(search) where(date: search).all else [] + flash[:notice] = "Sorry there is no match for your search criteria" end end @@ -32,6 +33,7 @@ def self.search_by_venue(search) where(venue: search).all else [] + flash[:notice] = "Sorry there is no match for your search criteria" end end @@ -47,6 +49,7 @@ def self.search_by_tour(search) where(tour: search).all else [] + flash[:notice] = "Sorry there is no match for your search criteria" end end end \ No newline at end of file diff --git a/app/models/song.rb b/app/models/song.rb index e6786aa..a8facad 100644 --- a/app/models/song.rb +++ b/app/models/song.rb @@ -1,5 +1,24 @@ class Song < ActiveRecord::Base attr_accessible :title, :media_link has_many :setlists + has_many :concerts, through: :setlists + + def times_played + self.concerts.count + end + + def first_time_played + "#{self.concerts.last.date.strftime('%m/%d/%Y')} at #{self.concerts.last.venue}" + end + + def last_time_played + "#{self.concerts.first.date.strftime('%m/%d/%Y')} at #{self.concerts.first.venue}" + end + + def avg_times_played + concerts = Concert.where("date >= ?", self.concerts.last.date) + total = ((times_played.to_f/concerts.count.to_f)*100).round(2) + "#{total}% of concerts since it was introduced in #{self.concerts.last.date.strftime('%Y')}" + end end \ No newline at end of file diff --git a/app/views/concerts/index.html.erb b/app/views/concerts/index.html.erb index 3ab2a5e..62987dc 100644 --- a/app/views/concerts/index.html.erb +++ b/app/views/concerts/index.html.erb @@ -6,24 +6,26 @@ <% end %>
    - <%- if @concerts.present? %> -

    <%= @search_term %> - <%= @concerts.count %>

    - <% @concerts.each do |concert| %> -

    - <%= link_to "#{concert.date.strftime('%m/%d/%Y')} - #{concert.venue}", "#", :class=>"setlist_button" %> -

    -
    -
      - <% concert.songs.each do |song| %> -
    1. <%= song.title %>
    2. + <%- if concerts.present? %> +

      <%= search_criteria %> - <%= concerts_count %>

      + <% concerts.each do |concert| %> + <%- if !concert.nil? %> +

      + <%= link_to "#{concert.date.strftime('%m/%d/%Y')} - #{concert.venue}", "#", :class=>"setlist_button" %> +

      +
      +
        + <% concert.songs.each do |song| %> +
      1. <%= link_to song.title, "songs/#{song.id}" %>
      2. + <% end %> +
      +
      + <% if user_signed_in? %> + <%= form_for concert.favorites.new do |f| %> + <%= f.label :favorite, :class=>"hidden_label" %> + <%= f.hidden_field(:concert_id) %> + <%= f.submit %> <% end %> -
    -
    - <% if user_signed_in? %> - <%= form_for concert.favorites.new do |f| %> - <%= f.label :favorite, :class=>"hidden_label" %> - <%= f.hidden_field(:concert_id) %> - <%= f.submit %> <% end %> <% end %> <% end %> diff --git a/app/views/concerts/songs/show.html.erb b/app/views/concerts/songs/show.html.erb new file mode 100644 index 0000000..252f018 --- /dev/null +++ b/app/views/concerts/songs/show.html.erb @@ -0,0 +1 @@ +<%= song.title %> \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1338498..4a9f1da 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -42,14 +42,14 @@

    Search by Venue

    <%= form_tag concerts_path, :method => 'get' do %> - <%= select_tag :search_by_venue, options_from_collection_for_select(@venues, "venue", "venue"), prompt: "Select something" %> + <%= select_tag :search_by_venue, options_from_collection_for_select(venue_options, "venue", "venue"), prompt: "Select something" %> <%= submit_tag "Search", :class => "searchbutton", :name => nil %> <% end %>

    Search by Tour

    <%= form_tag concerts_path, :method => 'get' do %> - <%= select_tag :search_by_tour, options_from_collection_for_select(@tours, "tour", "tour"), prompt: "Select something" %> + <%= select_tag :search_by_tour, options_from_collection_for_select(tour_options, "tour", "tour"), prompt: "Select something" %> <%= submit_tag "Search", :class => "searchbutton", :name => nil %> <% end %>
    diff --git a/app/views/songs/show.html.erb b/app/views/songs/show.html.erb new file mode 100644 index 0000000..5fd9f3f --- /dev/null +++ b/app/views/songs/show.html.erb @@ -0,0 +1,7 @@ +
    +

    <%= song.title %>

    +

    Was played at <%= song.times_played %> concerts

    +

    Introduced live on <%= song.first_time_played %>

    +

    Last played live on <%= song.last_time_played %>

    +

    Played on average <%= song.avg_times_played %>

    +
    \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 35f66f3..1aaa621 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,7 +5,7 @@ resources :concerts resources :concert_sets resources :setlists - resources :songs + resources :songs, only: [:create, :edit, :show, :index, :destroy] resources :favorites root :to => "concerts#index" From f86dd463a1024d0c8731decbeeea32a027284bcf Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Thu, 4 Jul 2013 23:32:31 -0500 Subject: [PATCH 10/19] More data/stats per song; working on getting set numbers in there --- app/helpers/concerts_helper.rb | 32 ++++++++++++++++++++++++++ app/models/setlist.rb | 3 +++ app/models/song.rb | 1 + app/views/layouts/application.html.erb | 2 +- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/helpers/concerts_helper.rb b/app/helpers/concerts_helper.rb index ac958f3..5c01b3c 100644 --- a/app/helpers/concerts_helper.rb +++ b/app/helpers/concerts_helper.rb @@ -6,6 +6,14 @@ def venue_options concerts.sort_by { |c| c.venue } end + def venues_count + venue_options.count + end + + def songs_count + Song.all.count + end + def tour_options concerts = Concert.all.map { |c| c } concerts.uniq! { |c| c.tour } @@ -22,4 +30,28 @@ def search_criteria "Today in Grateful Dead history" end end + + # def concert_sets(concert) + # first_set = [] + # second_set = [] + # third_set = [] + # encore = [] + # concert.setlists.each do |setlist| + # if setlist.group == "Set 1" + # first_set << [setlist.song.title, setlist.song_id, setlist.order] + # elsif setlist.group == "Set 2" + # second_set << [setlist.song.title, setlist.song_id, setlist.order] + # elsif setlist.group == "Set 3" + # third_set << [setlist.song.title, setlist.song_id, setlist.order] + # elsif setlist.group == "Encore:" + # binding.pry + # encore << [setlist.song.title, setlist.song_id, setlist.order] + # end + # end + # first_set.unshift(["Set 1", 0, 0]) + # second_set.unshift(["Set 2", 0, 0]) + # third_set.unshift(["Set 3", 0, 0]) + # encore.unshift(["Encore", 0, 0]) + # setlists = [first_set, second_set, third_set, encore] + # end end \ No newline at end of file diff --git a/app/models/setlist.rb b/app/models/setlist.rb index 88fe3f6..90adc54 100644 --- a/app/models/setlist.rb +++ b/app/models/setlist.rb @@ -2,4 +2,7 @@ class Setlist < ActiveRecord::Base attr_accessible :concert_id, :song_id, :order, :group belongs_to :concert belongs_to :song + + delegate :group, to: :song, prefix: true + end diff --git a/app/models/song.rb b/app/models/song.rb index a8facad..ab8a607 100644 --- a/app/models/song.rb +++ b/app/models/song.rb @@ -3,6 +3,7 @@ class Song < ActiveRecord::Base has_many :setlists has_many :concerts, through: :setlists + def times_played self.concerts.count end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 4a9f1da..7048438 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -40,7 +40,7 @@ <% end %>
    -

    Search by Venue

    +

    Search by Venue (<%= venues_count %>)

    <%= form_tag concerts_path, :method => 'get' do %> <%= select_tag :search_by_venue, options_from_collection_for_select(venue_options, "venue", "venue"), prompt: "Select something" %> <%= submit_tag "Search", :class => "searchbutton", :name => nil %> From d327263b8a09838fd555eb410d784db14789a1bc Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Fri, 12 Jul 2013 10:40:53 -0500 Subject: [PATCH 11/19] Break setlists into sets --- app/helpers/concerts_helper.rb | 23 ----------------------- app/models/concert.rb | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/app/helpers/concerts_helper.rb b/app/helpers/concerts_helper.rb index 5c01b3c..c967564 100644 --- a/app/helpers/concerts_helper.rb +++ b/app/helpers/concerts_helper.rb @@ -31,27 +31,4 @@ def search_criteria end end - # def concert_sets(concert) - # first_set = [] - # second_set = [] - # third_set = [] - # encore = [] - # concert.setlists.each do |setlist| - # if setlist.group == "Set 1" - # first_set << [setlist.song.title, setlist.song_id, setlist.order] - # elsif setlist.group == "Set 2" - # second_set << [setlist.song.title, setlist.song_id, setlist.order] - # elsif setlist.group == "Set 3" - # third_set << [setlist.song.title, setlist.song_id, setlist.order] - # elsif setlist.group == "Encore:" - # binding.pry - # encore << [setlist.song.title, setlist.song_id, setlist.order] - # end - # end - # first_set.unshift(["Set 1", 0, 0]) - # second_set.unshift(["Set 2", 0, 0]) - # third_set.unshift(["Set 3", 0, 0]) - # encore.unshift(["Encore", 0, 0]) - # setlists = [first_set, second_set, third_set, encore] - # end end \ No newline at end of file diff --git a/app/models/concert.rb b/app/models/concert.rb index 9f29d5a..ea284d5 100644 --- a/app/models/concert.rb +++ b/app/models/concert.rb @@ -52,4 +52,20 @@ def self.search_by_tour(search) flash[:notice] = "Sorry there is no match for your search criteria" end end + + def first_set + self.setlists.where(group: "Set 1") + end + + def second_set + self.setlists.where(group: "Set 2") + end + + def third_set + self.setlists.where(group: "Set 3") + end + + def encore + self.setlists.where(group: "Encore:") + end end \ No newline at end of file From cb1a6c171861801ed7c1aaea08e7a2503a8cd5da Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Fri, 12 Jul 2013 10:41:40 -0500 Subject: [PATCH 12/19] Collect info about songs in rake task --- db/migrate/20130630155649_create_songs.rb | 1 + db/schema.rb | 1 + lib/tasks/scrape_setlists.rake | 20 ++++++++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/db/migrate/20130630155649_create_songs.rb b/db/migrate/20130630155649_create_songs.rb index 35f0f7a..e8c38ac 100644 --- a/db/migrate/20130630155649_create_songs.rb +++ b/db/migrate/20130630155649_create_songs.rb @@ -3,6 +3,7 @@ def change create_table :songs do |t| t.string :title t.string :media_link + t.string :info t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index 4070c5f..f3fee87 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -40,6 +40,7 @@ create_table "songs", :force => true do |t| t.string "title" t.string "media_link" + t.string "info" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end diff --git a/lib/tasks/scrape_setlists.rake b/lib/tasks/scrape_setlists.rake index 6cf77e2..6d6a783 100644 --- a/lib/tasks/scrape_setlists.rake +++ b/lib/tasks/scrape_setlists.rake @@ -21,16 +21,28 @@ task :gd => :environment do end @concert = Concert.create(date: @date, venue: header[1], tour: header[2]) i = 1 + j = 1 concert_page.css("ol li").each do |l| - if l.text.delete("\n").match("Set") || l.text.delete("\n").match("Encore") - @group = l.text.delete("\n") + if l.text.delete("\n").blank? + @group = 1 + elsif l.text.delete("\n") == "Set 1" + @group = 1 + elsif l.text.delete("\n") == "Set 2" + @group = 2 + elsif l.text.delete("\n") == "Set 3" + @group = 3 + elsif l.text.delete("\n") == "Encore:" + @group = 4 else if l.children.children.children[0].present? title = l.children.children.children[0].text + if l.children.children.children[2].present? + info = l.children.children.children[2].text + l.children.children.children[3].text + l.children.children.children[4].text + end else - title = "blank" + title = "" end - song = Song.where(title: title).first_or_create + song = Song.where(title: title, media_link: media_link, info: info).first_or_create Setlist.create(song_id: song.id, order: i, concert_id: @concert.id, group: @group) i += 1 end From c60ce416c44d1e54eef16b06d20802abcd917532 Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Fri, 12 Jul 2013 10:43:32 -0500 Subject: [PATCH 13/19] Styling for sets and info --- app/assets/stylesheets/application.css | 10 ++++-- app/views/concerts/index.html.erb | 43 +++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index e54f945..f1ce9a3 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -64,13 +64,19 @@ ul { li { font-family: 'RobotoThin', sans-serif; font-size: 14px; - line-height: 20px; color: white; } +.info_part { + font-size: 10px; + color: #FFEAB5; + padding-left: 10px; + +} + a { font-family: 'RobotoThin', sans-serif; - font-size: 12px; + font-size: 14px; line-height: 20px; color: #b0b0af; text-decoration: none; diff --git a/app/views/concerts/index.html.erb b/app/views/concerts/index.html.erb index 62987dc..062ac4f 100644 --- a/app/views/concerts/index.html.erb +++ b/app/views/concerts/index.html.erb @@ -11,14 +11,47 @@ <% concerts.each do |concert| %> <%- if !concert.nil? %>

    - <%= link_to "#{concert.date.strftime('%m/%d/%Y')} - #{concert.venue}", "#", :class=>"setlist_button" %> + <%= link_to "#{concert.date.strftime('%m/%d/%Y')} - #{concert.venue} - #{concert.id}", "#", :class=>"setlist_button" %>

    -
      - <% concert.songs.each do |song| %> -
    1. <%= link_to song.title, "songs/#{song.id}" %>
    2. + <% if concert.first_set.present? %> +
        +
      • Set 1
      • + <% concert.first_set.each do |set| %> +
      • <%= link_to set.song.title, "songs/#{set.song.id}" %><%= set.song.info %>
      • + <% end %> +
      +
        +
      • Set 2
      • + <% concert.second_set.each do |set| %> +
      • <%= link_to set.song.title, "songs/#{set.song.id}" %><%= set.song.info %>
      • + <% end %> +
      + <% if concert.third_set.present? %> +
        +
      • Set 3
      • + <% concert.third_set.each do |set| %> +
      • <%= link_to set.song.title, "songs/#{set.song.id}" %><%= set.song.info %>
      • + <% end %> +
      <% end %> -
    +
      +
    • Encore
    • + <% concert.encore.each do |set| %> +
    • <%= link_to set.song.title, "songs/#{set.song.id}" %><%= set.song.info %>
    • + <% end %> +
    + <% else %> + <% if concert.setlists.empty? %> +

    No songs have been recorded for this concert

    + <% else %> +
      + <% concert.setlists.each do |set| %> +
    • <%= link_to set.song.title, "songs/#{set.song.id}" %><%= set.song.info %>
    • + <% end %> +
    + <% end %> + <% end %>
    <% if user_signed_in? %> <%= form_for concert.favorites.new do |f| %> From 39933091e01e642098177b41d640a3df26ee9e7a Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Fri, 12 Jul 2013 10:45:19 -0500 Subject: [PATCH 14/19] New scraper gets info and set breaks --- lib/tasks/scrape_setlists.rake | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/tasks/scrape_setlists.rake b/lib/tasks/scrape_setlists.rake index 6d6a783..73d8aab 100644 --- a/lib/tasks/scrape_setlists.rake +++ b/lib/tasks/scrape_setlists.rake @@ -4,7 +4,7 @@ task :gd => :environment do require 'open-uri' @links_count = 0 # This range can be set up to 196. It must be set at 196 to retrieve all 1955 concerts. - range = (1..1).to_a + range = (1..196).to_a range.each do |i| page = Nokogiri::HTML(open("http://www.setlist.fm/setlists/grateful-dead-bd6ad4a.html?page=#{i}")) # Nokogiri supports CSS-style selectors @@ -21,18 +21,9 @@ task :gd => :environment do end @concert = Concert.create(date: @date, venue: header[1], tour: header[2]) i = 1 - j = 1 concert_page.css("ol li").each do |l| - if l.text.delete("\n").blank? - @group = 1 - elsif l.text.delete("\n") == "Set 1" - @group = 1 - elsif l.text.delete("\n") == "Set 2" - @group = 2 - elsif l.text.delete("\n") == "Set 3" - @group = 3 - elsif l.text.delete("\n") == "Encore:" - @group = 4 + if l.text.delete("\n").match("Set") || l.text.delete("\n").match("Encore:") + @group = l.text.delete("\n") else if l.children.children.children[0].present? title = l.children.children.children[0].text @@ -40,9 +31,9 @@ task :gd => :environment do info = l.children.children.children[2].text + l.children.children.children[3].text + l.children.children.children[4].text end else - title = "" + title = nil end - song = Song.where(title: title, media_link: media_link, info: info).first_or_create + song = Song.where(title: title, info: info).first_or_create Setlist.create(song_id: song.id, order: i, concert_id: @concert.id, group: @group) i += 1 end From a8dd11e6918ef6fff5236b3516907e305c06ca99 Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Fri, 12 Jul 2013 10:45:40 -0500 Subject: [PATCH 15/19] rvmrc file sets ruby version --- .rvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .rvmrc diff --git a/.rvmrc b/.rvmrc new file mode 100644 index 0000000..a2e98ad --- /dev/null +++ b/.rvmrc @@ -0,0 +1 @@ +rvm use --create 2.0.0-p0@capstone-deadsets \ No newline at end of file From 1e9d8b3186ec84c6ca6f946fe43f5098d6643b0f Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sat, 13 Jul 2013 21:18:06 -0500 Subject: [PATCH 16/19] New styling for favorite concerts --- app/views/concerts/index.html.erb | 3 -- app/views/favorites/index.html.erb | 51 ++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/app/views/concerts/index.html.erb b/app/views/concerts/index.html.erb index 062ac4f..b029b95 100644 --- a/app/views/concerts/index.html.erb +++ b/app/views/concerts/index.html.erb @@ -4,7 +4,6 @@ <% flash.discard(:notice) %>
    <% end %> -
    <%- if concerts.present? %>

    <%= search_criteria %> - <%= concerts_count %>

    @@ -63,7 +62,5 @@ <% end %> <% end %> <% end %> - -
    diff --git a/app/views/favorites/index.html.erb b/app/views/favorites/index.html.erb index db27646..a600d6b 100644 --- a/app/views/favorites/index.html.erb +++ b/app/views/favorites/index.html.erb @@ -12,16 +12,49 @@ <% if @favorites.any? %>

    Favorite Concerts

    <% @favorites.each do |favorite| %> -

    - <%= link_to "#{favorite.concert.date} - #{favorite.concert.venue} - #{favorite.concert.tour}", "#", :class=>"setlist_button" %> -

    -
    -
      - <% favorite.concert.songs.each do |song| %> -
    • <%= song.title %>
    • +

      + <%= link_to "#{favorite.concert.date} - #{favorite.concert.venue} - #{favorite.concert.tour}", "#", :class=>"setlist_button" %> +

      +
      + <% if favorite.concert.first_set.present? %> +
        +
      • Set 1
      • + <% favorite.concert.first_set.each do |set| %> +
      • <%= link_to set.song.title, "songs/#{set.song.id}" %><%= set.song.info %>
      • + <% end %> +
      +
        +
      • Set 2
      • + <% favorite.concert.second_set.each do |set| %> +
      • <%= link_to set.song.title, "songs/#{set.song.id}" %><%= set.song.info %>
      • + <% end %> +
      + <% if favorite.concert.third_set.present? %> +
        +
      • Set 3
      • + <% favorite.concert.third_set.each do |set| %> +
      • <%= link_to set.song.title, "songs/#{set.song.id}" %><%= set.song.info %>
      • + <% end %> +
      + <% end %> +
        +
      • Encore
      • + <% favorite.concert.encore.each do |set| %> +
      • <%= link_to set.song.title, "songs/#{set.song.id}" %><%= set.song.info %>
      • + <% end %> +
      + <% else %> + <% if favorite.concert.setlists.empty? %> +

      No songs have been recorded for this concert

      + <% else %> +
        + <% favorite.concert.setlists.each do |set| %> +
      • <%= link_to set.song.title, "songs/#{set.song.id}" %><%= set.song.info %>
      • + <% end %> +
      + <% end %> <% end %> -
    -
    + <%= button_to "Delete", favorite, :method=>:delete, :class=>"deletebutton" %> <% end %> <% end %> From eb0826094ad369a9438b9258032fe7d6b272e7b3 Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sat, 13 Jul 2013 21:18:29 -0500 Subject: [PATCH 17/19] Scraper fixes set indentifiers --- lib/tasks/scrape_setlists.rake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/tasks/scrape_setlists.rake b/lib/tasks/scrape_setlists.rake index 73d8aab..c424d9a 100644 --- a/lib/tasks/scrape_setlists.rake +++ b/lib/tasks/scrape_setlists.rake @@ -2,7 +2,6 @@ desc 'Scrape grateful dead setlists from setlist.fm' task :gd => :environment do require 'nokogiri' require 'open-uri' - @links_count = 0 # This range can be set up to 196. It must be set at 196 to retrieve all 1955 concerts. range = (1..196).to_a range.each do |i| @@ -40,5 +39,12 @@ task :gd => :environment do end end end - puts "The database was seeded with #{@links.count} concerts and their songs." + Setlist.where(group: "Set One").each do |set| + set.group = "Set 1" + set.save + end + Setlist.where(group: "Set Two").each do |set| + set.group = "Set 2" + set.save + end end \ No newline at end of file From 632b926f75601a46a0006639ec606deff9185cb8 Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sat, 13 Jul 2013 21:32:00 -0500 Subject: [PATCH 18/19] Scraper fixes --- lib/tasks/scrape_setlists.rake | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/tasks/scrape_setlists.rake b/lib/tasks/scrape_setlists.rake index 73d8aab..c0869c6 100644 --- a/lib/tasks/scrape_setlists.rake +++ b/lib/tasks/scrape_setlists.rake @@ -2,9 +2,8 @@ desc 'Scrape grateful dead setlists from setlist.fm' task :gd => :environment do require 'nokogiri' require 'open-uri' - @links_count = 0 # This range can be set up to 196. It must be set at 196 to retrieve all 1955 concerts. - range = (1..196).to_a + range = (39..39).to_a range.each do |i| page = Nokogiri::HTML(open("http://www.setlist.fm/setlists/grateful-dead-bd6ad4a.html?page=#{i}")) # Nokogiri supports CSS-style selectors @@ -40,5 +39,18 @@ task :gd => :environment do end end end - puts "The database was seeded with #{@links.count} concerts and their songs." + Setlist.where(group: "Set One").each do |set| + set.group = "Set 1" + set.save + end + Setlist.where(group: "Set Two").each do |set| + set.group = "Set 2" + set.save + end + song = Song.where(title: nil).first.destroy + Setlist.where(song_id: song.id).each do |set| + set.destroy + end + puts "Concerts: #{Concert.all.count}" + puts "Songs: #{Song.all.count}" end \ No newline at end of file From e0c2da4fea1f94c954698a5893bc0a61035eeaec Mon Sep 17 00:00:00 2001 From: Ben Bridges Date: Sat, 13 Jul 2013 21:55:30 -0500 Subject: [PATCH 19/19] Scraper fixes and remove concert id from viewsd --- app/views/concerts/index.html.erb | 2 +- lib/tasks/scrape_setlists.rake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/concerts/index.html.erb b/app/views/concerts/index.html.erb index b029b95..285cdc3 100644 --- a/app/views/concerts/index.html.erb +++ b/app/views/concerts/index.html.erb @@ -10,7 +10,7 @@ <% concerts.each do |concert| %> <%- if !concert.nil? %>

    - <%= link_to "#{concert.date.strftime('%m/%d/%Y')} - #{concert.venue} - #{concert.id}", "#", :class=>"setlist_button" %> + <%= link_to "#{concert.date.strftime('%m/%d/%Y')} - #{concert.venue}", "#", :class=>"setlist_button" %>

    <% if concert.first_set.present? %> diff --git a/lib/tasks/scrape_setlists.rake b/lib/tasks/scrape_setlists.rake index c0869c6..c9e2feb 100644 --- a/lib/tasks/scrape_setlists.rake +++ b/lib/tasks/scrape_setlists.rake @@ -3,7 +3,7 @@ task :gd => :environment do require 'nokogiri' require 'open-uri' # This range can be set up to 196. It must be set at 196 to retrieve all 1955 concerts. - range = (39..39).to_a + range = (1..196).to_a range.each do |i| page = Nokogiri::HTML(open("http://www.setlist.fm/setlists/grateful-dead-bd6ad4a.html?page=#{i}")) # Nokogiri supports CSS-style selectors