From baf40d32a442b8bccdd21b35021f7df2cec02888 Mon Sep 17 00:00:00 2001 From: Hunter Posey Date: Thu, 3 Dec 2020 14:45:26 -0800 Subject: [PATCH 01/19] first commit-API key acquired --- Gemfile | 1 + Gemfile.lock | 65 +++++++++++-------- app/models/artist.rb | 4 ++ app/models/show_dates.rb | 4 ++ app/models/venue.rb | 4 ++ config/environment.rb | 5 +- db/migrate/20201203003537_create_artist.rb | 7 ++ db/migrate/20201203003625_create_venue.rb | 9 +++ db/migrate/20201203175042_create_show_date.rb | 9 +++ db/schema.rb | 31 +++++++++ db/seeds.rb | 23 +++++++ 11 files changed, 132 insertions(+), 30 deletions(-) create mode 100644 app/models/artist.rb create mode 100644 app/models/show_dates.rb create mode 100644 app/models/venue.rb create mode 100644 db/migrate/20201203003537_create_artist.rb create mode 100644 db/migrate/20201203003625_create_venue.rb create mode 100644 db/migrate/20201203175042_create_show_date.rb create mode 100644 db/schema.rb create mode 100644 db/seeds.rb diff --git a/Gemfile b/Gemfile index c004f4ca..558abf44 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,4 @@ gem "sinatra-activerecord" gem "sqlite3" gem "pry" gem "require_all" +gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'master' #require faker \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 9589226d..f50eb89f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,56 +1,65 @@ +GIT + remote: https://github.com/faker-ruby/faker.git + revision: ec06d217644cf3d66bd0e658c9b168af8f0c38c7 + branch: master + specs: + faker (2.15.1) + i18n (>= 1.6, < 2) + GEM remote: https://rubygems.org/ specs: - activemodel (6.0.3.1) - activesupport (= 6.0.3.1) - activerecord (6.0.3.1) - activemodel (= 6.0.3.1) - activesupport (= 6.0.3.1) - activesupport (6.0.3.1) + activemodel (6.0.3.4) + activesupport (= 6.0.3.4) + activerecord (6.0.3.4) + activemodel (= 6.0.3.4) + activesupport (= 6.0.3.4) + activesupport (6.0.3.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) zeitwerk (~> 2.2, >= 2.2.2) - coderay (1.1.1) - concurrent-ruby (1.1.6) - i18n (1.8.2) + coderay (1.1.3) + concurrent-ruby (1.1.7) + i18n (1.8.5) concurrent-ruby (~> 1.0) - method_source (0.8.2) - minitest (5.14.1) - mustermann (1.0.3) - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) + method_source (1.0.0) + minitest (5.14.2) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) rack (2.2.3) - rack-protection (2.0.7) + rack-protection (2.1.0) rack - require_all (1.3.3) - sinatra (2.0.7) + require_all (3.0.0) + ruby2_keywords (0.0.2) + sinatra (2.1.0) mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.7) + rack (~> 2.2) + rack-protection (= 2.1.0) tilt (~> 2.0) - sinatra-activerecord (2.0.12) - activerecord (>= 3.2) + sinatra-activerecord (2.0.21) + activerecord (>= 4.1) sinatra (>= 1.0) - slop (3.6.0) - sqlite3 (1.3.13) + sqlite3 (1.4.2) thread_safe (0.3.6) tilt (2.0.10) - tzinfo (1.2.7) + tzinfo (1.2.8) thread_safe (~> 0.1) - zeitwerk (2.3.0) + zeitwerk (2.4.2) PLATFORMS ruby DEPENDENCIES + faker! pry require_all sinatra-activerecord sqlite3 BUNDLED WITH - 1.14.6 + 2.1.4 diff --git a/app/models/artist.rb b/app/models/artist.rb new file mode 100644 index 00000000..99d1787b --- /dev/null +++ b/app/models/artist.rb @@ -0,0 +1,4 @@ +class Artist < ActiveRecord::Base + has_many :show_dates + has_many :venues, through: :show_dates +end \ No newline at end of file diff --git a/app/models/show_dates.rb b/app/models/show_dates.rb new file mode 100644 index 00000000..11c9761a --- /dev/null +++ b/app/models/show_dates.rb @@ -0,0 +1,4 @@ +class ShowDate < ActiveRecord::Base + belongs_to :artist + belongs_to :venue +end \ No newline at end of file diff --git a/app/models/venue.rb b/app/models/venue.rb new file mode 100644 index 00000000..f060f065 --- /dev/null +++ b/app/models/venue.rb @@ -0,0 +1,4 @@ +class Venue < ActiveRecord::Base + has_many :show_dates + has_many :artists, through: :show_dates +end \ No newline at end of file diff --git a/config/environment.rb b/config/environment.rb index 4dbe13e5..5bd47fdd 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,6 @@ require 'bundler' Bundler.require -ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') -require_all 'lib' +require_all 'app/models' + +ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') \ No newline at end of file diff --git a/db/migrate/20201203003537_create_artist.rb b/db/migrate/20201203003537_create_artist.rb new file mode 100644 index 00000000..fa459d7f --- /dev/null +++ b/db/migrate/20201203003537_create_artist.rb @@ -0,0 +1,7 @@ +class CreateArtist < ActiveRecord::Migration[6.0] + def change + create_table :artists do |t| + t.string :name + end + end +end diff --git a/db/migrate/20201203003625_create_venue.rb b/db/migrate/20201203003625_create_venue.rb new file mode 100644 index 00000000..af4c092e --- /dev/null +++ b/db/migrate/20201203003625_create_venue.rb @@ -0,0 +1,9 @@ +class CreateVenue < ActiveRecord::Migration[6.0] + def change + create_table :venues do |t| + t.string :name + t.string :city + t.string :state + end + end +end diff --git a/db/migrate/20201203175042_create_show_date.rb b/db/migrate/20201203175042_create_show_date.rb new file mode 100644 index 00000000..915ce559 --- /dev/null +++ b/db/migrate/20201203175042_create_show_date.rb @@ -0,0 +1,9 @@ +class CreateShowDate < ActiveRecord::Migration[6.0] + def change + create_table :show_dates do |t| + t.datetime :date + t.integer :venue_id + t.integer :artist_id + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 00000000..37fabb4f --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,31 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `rails +# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_12_03_175042) do + + create_table "artists", force: :cascade do |t| + t.string "name" + end + + create_table "show_dates", force: :cascade do |t| + t.datetime "date" + t.integer "venue_id" + t.integer "artist_id" + end + + create_table "venues", force: :cascade do |t| + t.string "name" + t.string "city" + t.string "state" + end + +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000..33e0ebbd --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,23 @@ +require 'faker' + +#key = KA7HJvpLeeJHtp4Y2SkcGVzOmw9AAmJ1 +#https://app.ticketmaster.com/discovery/v2/venues.json?apikey=KA7HJvpLeeJHtp4Y2SkcGVzOmw9AAmJ1 + +Artist.destroy_all +ShowDate.destroy_all +Venue.destroy_all + +10.times do + Artist.create(name:Faker::Music.band) +end +puts 'done' + +10.times do + Venue.create(name:Faker::GreekPhilosophers.name, city:Faker::Address.city, state:Faker::Address.state) +end +puts 'done' + +10.times do + ShowDate.create(date:Faker::Date.backward(days: 19000), venue_id: Venue.all.sample.id, artist_id: Artist.all.sample.id) +end +puts 'done' \ No newline at end of file From 534a1fd4905b571197144abb2d40cdf384d1eebb Mon Sep 17 00:00:00 2001 From: dangnhon Date: Thu, 3 Dec 2020 16:15:41 -0800 Subject: [PATCH 02/19] API is working --- app/models/artist.rb | 3 ++- app/models/get_requester.rb | 19 +++++++++++++++++++ app/models/venue.rb | 6 ++++++ db/seeds.rb | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 app/models/get_requester.rb diff --git a/app/models/artist.rb b/app/models/artist.rb index 99d1787b..3bd0151a 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -1,4 +1,5 @@ class Artist < ActiveRecord::Base has_many :show_dates has_many :venues, through: :show_dates -end \ No newline at end of file +end + diff --git a/app/models/get_requester.rb b/app/models/get_requester.rb new file mode 100644 index 00000000..f93a87cf --- /dev/null +++ b/app/models/get_requester.rb @@ -0,0 +1,19 @@ +require 'open-uri' +require 'net/http' +require 'json' + +class GetRequester + def initialize(url) + @url = url + end + + def get_response_body + uri = URI.parse(@url) + response = Net::HTTP.get_response(uri) + response.body + end + + def parse_json + JSON.parse(get_response_body) + end +end diff --git a/app/models/venue.rb b/app/models/venue.rb index f060f065..8dc6fdc7 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -1,4 +1,10 @@ class Venue < ActiveRecord::Base has_many :show_dates has_many :artists, through: :show_dates + + def find_venue(keyword) + res = GetRequester.new("https://app.ticketmaster.com/discovery/v2/venues.json?apikey=KA7HJvpLeeJHtp4Y2SkcGVzOmw9AAmJ1&keyword=#{keyword}") + data = res.parse_json + data["_embedded"]["venues"][0]["name"] + end end \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index 33e0ebbd..4f4b5f5b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -2,6 +2,7 @@ #key = KA7HJvpLeeJHtp4Y2SkcGVzOmw9AAmJ1 #https://app.ticketmaster.com/discovery/v2/venues.json?apikey=KA7HJvpLeeJHtp4Y2SkcGVzOmw9AAmJ1 +# if you want keyword searchability, add &keyword=#{interpolated_passed_here} to the end of apikey in the url Artist.destroy_all ShowDate.destroy_all From 10de9239ed8815d5d57662f2f460bf9f2a8f05a7 Mon Sep 17 00:00:00 2001 From: dangnhon Date: Thu, 3 Dec 2020 20:30:52 -0800 Subject: [PATCH 03/19] change to option 2 --- app/models/artist.rb | 28 +++++++++++++++++++++++++++- app/models/get_requester.rb | 19 ------------------- app/models/show_dates.rb | 11 ++++++++++- app/models/venue.rb | 6 ------ db/seeds.rb | 17 ++++++++++++++--- 5 files changed, 51 insertions(+), 30 deletions(-) delete mode 100644 app/models/get_requester.rb diff --git a/app/models/artist.rb b/app/models/artist.rb index 3bd0151a..c5691509 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -1,5 +1,31 @@ class Artist < ActiveRecord::Base has_many :show_dates - has_many :venues, through: :show_dates + has_many :venues, through: :show_dates + + #THIS "ME" METHOD WORKS(KEEP) + def self.me(username) + self.all.find_or_create_by(name:username) + end + + def self.show_my_venue_name + ShowDate.all.select do |performance| + binding.pry + performance.artist_id == self.id + end + + end + + def delete_myself(username) + + end + + + + + + end +#technically the user model + +#Artist concert tracker program \ No newline at end of file diff --git a/app/models/get_requester.rb b/app/models/get_requester.rb deleted file mode 100644 index f93a87cf..00000000 --- a/app/models/get_requester.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'open-uri' -require 'net/http' -require 'json' - -class GetRequester - def initialize(url) - @url = url - end - - def get_response_body - uri = URI.parse(@url) - response = Net::HTTP.get_response(uri) - response.body - end - - def parse_json - JSON.parse(get_response_body) - end -end diff --git a/app/models/show_dates.rb b/app/models/show_dates.rb index 11c9761a..55117e07 100644 --- a/app/models/show_dates.rb +++ b/app/models/show_dates.rb @@ -1,4 +1,13 @@ class ShowDate < ActiveRecord::Base belongs_to :artist belongs_to :venue -end \ No newline at end of file + + # def create_date_for_artist(artist_name) + # artist_date = ShowDate.find_or_create_by(date:) + # binding.pry + # end + + +end + +#full CRUD \ No newline at end of file diff --git a/app/models/venue.rb b/app/models/venue.rb index 8dc6fdc7..f060f065 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -1,10 +1,4 @@ class Venue < ActiveRecord::Base has_many :show_dates has_many :artists, through: :show_dates - - def find_venue(keyword) - res = GetRequester.new("https://app.ticketmaster.com/discovery/v2/venues.json?apikey=KA7HJvpLeeJHtp4Y2SkcGVzOmw9AAmJ1&keyword=#{keyword}") - data = res.parse_json - data["_embedded"]["venues"][0]["name"] - end end \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index 4f4b5f5b..a0ca9330 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -8,17 +8,28 @@ ShowDate.destroy_all Venue.destroy_all -10.times do +# drake = Artist.create(name: "drake") +# slim = Artist.create(name: "slim") +# nas = Artist.create(name: "nas") + +# v1 = Venue.create(name: "Tuscaloosa Ampitheater", city: "Tuscaloosa", state: "Alabama") +# v2 = Venue.create(name: "The Greek", city: "Los Angeles", state: "California") +# v3 = Venue.create(name: "The Gorge Ampitheater", city: "George", state: "Washington") + +# sd1 = ShowDate.create(date:Faker::Date.backward(days: 19000), venue_id: Venue.all.sample.id, artist_id: Artist.all.sample.id) +# sd2 = ShowDate.create(date:Faker::Date.backward(days: 19000), venue_id: Venue.all.sample.id, artist_id: Artist.all.sample.id) +# sd3 = ShowDate.create(date:Faker::Date.backward(days: 19000), venue_id: Venue.all.sample.id, artist_id: Artist.all.sample.id) +15.times do Artist.create(name:Faker::Music.band) end puts 'done' -10.times do +15.times do Venue.create(name:Faker::GreekPhilosophers.name, city:Faker::Address.city, state:Faker::Address.state) end puts 'done' -10.times do +15.times do ShowDate.create(date:Faker::Date.backward(days: 19000), venue_id: Venue.all.sample.id, artist_id: Artist.all.sample.id) end puts 'done' \ No newline at end of file From e5fb314f58384fe3b464df84f7428e4c72e417a7 Mon Sep 17 00:00:00 2001 From: dangnhon Date: Fri, 4 Dec 2020 11:46:18 -0800 Subject: [PATCH 04/19] starting CLI --- README.md | 60 ++++------------------------------------ app/models/artist.rb | 52 ++++++++++++++++++++-------------- app/models/show_dates.rb | 9 +----- app/models/venue.rb | 4 +++ bin/run.rb | 22 ++++++++++++++- config/cli_commands.rb | 26 +++++++++++++++++ db/seeds.rb | 3 ++ 7 files changed, 91 insertions(+), 85 deletions(-) create mode 100644 config/cli_commands.rb diff --git a/README.md b/README.md index b75f6185..413d03a7 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,9 @@ -# Module One Final Project Guidelines +# As a user, I would like to: + -### Option One - Data Analytics Project - -1. Access a Sqlite3 Database using ActiveRecord. -2. You should have at minimum three models including one join model. This means you must have a many-to-many relationship. -3. You should seed your database using data that you collect either from a CSV, a website by scraping, or an API. -4. Your models should have methods that answer interesting questions about the data. For example, if you've collected info about movie reviews, what is the most popular movie? What movie has the most reviews? -5. You should provide a CLI to display the return values of your interesting methods. -6. Use good OO design patterns. You should have separate classes for your models and CLI interface. - - **Resource:** [Easy Access APIs](https://github.com/learn-co-curriculum/easy-access-apis) - -### Option Two - Command Line CRUD App - -1. Access a Sqlite3 Database using ActiveRecord. -2. You should have a minimum of three models. -3. You should build out a CLI to give your user full CRUD ability for at least one of your resources. For example, build out a command line To-Do list. A user should be able to create a new to-do, see all todos, update a todo item, and delete a todo. Todos can be grouped into categories, so that a to-do has many categories and categories have many to-dos. -4. Use good OO design patterns. You should have separate classes for your models and CLI interface. - -### Brainstorming and Proposing a Project Idea - -Projects need to be approved prior to launching into them, so take some time to brainstorm project options that will fulfill the requirements above. You must have a minimum of four [user stories](https://en.wikipedia.org/wiki/User_story) to help explain how a user will interact with your app. A user story should follow the general structure of `"As a , I want so that "`. For example, if we were creating an app to randomly choose nearby restaurants on Yelp, we might write: - -* As a user, I want to be able to enter my name to retrieve my records -* As a user, I want to enter a location and be given a random nearby restaurant suggestion -* As a user, I should be able to reject a suggestion and not see that restaurant suggestion again -* As a user, I want to be able to save to and retrieve a list of favorite restaurant suggestions - -## Instructions - -1. Fork and clone this repository. -2. Build your application. Make sure to commit early and commit often. Commit messages should be meaningful (clearly describe what you're doing in the commit) and accurate (there should be nothing in the commit that doesn't match the description in the commit message). Good rule of thumb is to commit every 3-7 mins of actual coding time. Most of your commits should have under 15 lines of code and a 2 line commit is perfectly acceptable. -3. Make sure to create a good README.md with a short description, install instructions, a contributor's guide and a link to the license for your code. -4. Make sure your project checks off each of the above requirements. -5. Prepare a video demo (narration helps!) describing how a user would interact with your working project. - * The video should: - - Have an overview of your project. (2 minutes max) -6. Prepare a presentation to follow your video. (3 minutes max) - * Your presentation should: - - Describe something you struggled to build, and show us how you ultimately implemented it in your code. - - Discuss 3 things you learned in the process of working on this project. - - Address what, if anything, you would change or add to what you have today. - - Present any code you would like to highlight. -7. *OPTIONAL, BUT RECOMMENDED*: Write a blog post about the project and process. - ---- -### Common Questions: -- How do I turn off my SQL logger? -```ruby -# in config/environment.rb add this line: -ActiveRecord::Base.logger = nil -``` diff --git a/app/models/artist.rb b/app/models/artist.rb index c5691509..171d674c 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -2,27 +2,37 @@ class Artist < ActiveRecord::Base has_many :show_dates has_many :venues, through: :show_dates - #THIS "ME" METHOD WORKS(KEEP) - def self.me(username) - self.all.find_or_create_by(name:username) - end - - def self.show_my_venue_name - ShowDate.all.select do |performance| - binding.pry - performance.artist_id == self.id - end - - end - - def delete_myself(username) - - end - - - - - + #THIS CREATE METHOD WORKS(KEEP) + # def self.find_or_create_me(username) + # username = self.find_or_create_by(name:username) + # end + + # def create_date_for_artist + # ShowDate.find_or_create_by(date: datetime) + # binding.pry + # end + + #helper function to get primary key ID + # def self.all_venue_id + # artist_id_array = ShowDate.ids + # end + + # def self.show_venue_name(username) + # artist_venue = [] + # ShowDate.all.select do |info| + # #binding.pry + # if info.artist.name == username + # return info.venue.name + # else + # return "please create an account" + # end + # end + # end + + # def delete_myself(username) + # if username == self + # self + # end end diff --git a/app/models/show_dates.rb b/app/models/show_dates.rb index 55117e07..583cad8d 100644 --- a/app/models/show_dates.rb +++ b/app/models/show_dates.rb @@ -1,13 +1,6 @@ class ShowDate < ActiveRecord::Base belongs_to :artist belongs_to :venue - - # def create_date_for_artist(artist_name) - # artist_date = ShowDate.find_or_create_by(date:) - # binding.pry - # end - - -end +end #full CRUD \ No newline at end of file diff --git a/app/models/venue.rb b/app/models/venue.rb index f060f065..a42916ae 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -1,4 +1,8 @@ class Venue < ActiveRecord::Base has_many :show_dates has_many :artists, through: :show_dates + + def self.get_cities + self.all.map{|venue_instance| venue_instance.city}.uniq + end end \ No newline at end of file diff --git a/bin/run.rb b/bin/run.rb index cf08c338..f134d121 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -1,5 +1,25 @@ +require_relative '../config/cli_commands' require_relative '../config/environment' +user_selection = "main menu" +puts `clear` +puts "Welcome to our Artist App Tracker!" -puts "HELLO WORLD" +while true do + case user_selection + when "main menu" + user_selection = main_menu + when "list cities" + list_all_cities + user_selection = "main menu" + when "create account" + create_account + #user_selection = "Welcome #{user_input}" + when "exit" + break + else + ask_for_new_input + user_selection = "main menu" + end +end diff --git a/config/cli_commands.rb b/config/cli_commands.rb new file mode 100644 index 00000000..bb6da4fc --- /dev/null +++ b/config/cli_commands.rb @@ -0,0 +1,26 @@ +def main_menu + puts "What would you like to do?" + puts "1. list cities" + puts "2. create account" + puts "3. create a show" + puts "4. delete my show" + puts "5. exit" + user_input = gets.chomp +end + + +def list_all_cities + all_cities = Venue.get_cities + all_cities.each_with_index{|city, index| puts "#{index + 1}. #{city}"} +end + +def create_account + puts "Type in your band name" + user_input = gets.chomp + new_account = Artist.find_or_create_by(name: user_input) + puts "Welcome #{user_input}" +end + +def ask_for_new_input + puts "That was not a valid input, please try again" +end \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index a0ca9330..f86abe3d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,6 +4,9 @@ #https://app.ticketmaster.com/discovery/v2/venues.json?apikey=KA7HJvpLeeJHtp4Y2SkcGVzOmw9AAmJ1 # if you want keyword searchability, add &keyword=#{interpolated_passed_here} to the end of apikey in the url +# in config/environment.rb add this line: +# ActiveRecord::Base.logger = nil + Artist.destroy_all ShowDate.destroy_all Venue.destroy_all From 0c6dad6fe7deb576baff2098e42cddb84b282f46 Mon Sep 17 00:00:00 2001 From: dangnhon Date: Fri, 4 Dec 2020 14:58:23 -0800 Subject: [PATCH 05/19] some progress --- app/models/artist.rb | 13 ++++++++++--- {config => app/models}/cli_commands.rb | 11 ++++++++++- app/models/show_dates.rb | 12 ++++++++++++ bin/run.rb | 11 +++++++---- 4 files changed, 39 insertions(+), 8 deletions(-) rename {config => app/models}/cli_commands.rb (69%) diff --git a/app/models/artist.rb b/app/models/artist.rb index 171d674c..0f973767 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -3,9 +3,16 @@ class Artist < ActiveRecord::Base has_many :venues, through: :show_dates #THIS CREATE METHOD WORKS(KEEP) - # def self.find_or_create_me(username) - # username = self.find_or_create_by(name:username) - # end + def self.find_or_create_me(username) + username = self.find_or_create_by(name:username) + end + + def all_my_venues + ShowDate.all.map do |show_instance| + show_instance.venue + end + end + # def create_date_for_artist # ShowDate.find_or_create_by(date: datetime) diff --git a/config/cli_commands.rb b/app/models/cli_commands.rb similarity index 69% rename from config/cli_commands.rb rename to app/models/cli_commands.rb index bb6da4fc..50affbef 100644 --- a/config/cli_commands.rb +++ b/app/models/cli_commands.rb @@ -17,10 +17,19 @@ def list_all_cities def create_account puts "Type in your band name" user_input = gets.chomp - new_account = Artist.find_or_create_by(name: user_input) + new_account = Artist.find_or_create_me(user_input) puts "Welcome #{user_input}" + return new_account end +def create_a_show + puts "Where would you like to play?" + user_input = gets.chomp + new_show = ShowDate.create + puts "Your date is" + return new_show +end + def ask_for_new_input puts "That was not a valid input, please try again" end \ No newline at end of file diff --git a/app/models/show_dates.rb b/app/models/show_dates.rb index 583cad8d..0e56f51e 100644 --- a/app/models/show_dates.rb +++ b/app/models/show_dates.rb @@ -3,4 +3,16 @@ class ShowDate < ActiveRecord::Base belongs_to :venue end +def self.show_or_create(year, month, date) + binding.pry + self.find_or_create_by(date: Time.now(year, month, date)) +end + +def self.test + puts "helo" +end + + + + #full CRUD \ No newline at end of file diff --git a/bin/run.rb b/bin/run.rb index f134d121..b46db3a5 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -1,11 +1,11 @@ -require_relative '../config/cli_commands' +#require_relative '../config/cli_commands' require_relative '../config/environment' user_selection = "main menu" puts `clear` puts "Welcome to our Artist App Tracker!" - +artist = nil while true do case user_selection when "main menu" @@ -14,8 +14,11 @@ list_all_cities user_selection = "main menu" when "create account" - create_account - #user_selection = "Welcome #{user_input}" + artist = create_account + user_selection = "Welcome!" + when "Welcome!" + create_a_show + #user_selection = "something" when "exit" break else From 5909fdd0ce8933a29a58bb8fc457841006ed2dd1 Mon Sep 17 00:00:00 2001 From: dangnhon Date: Fri, 4 Dec 2020 17:38:55 -0800 Subject: [PATCH 06/19] got a method down --- app/models/artist.rb | 35 +++---------------- .../{cli_commands.rb => cli_command.rb} | 4 +-- app/models/show_date.rb | 22 ++++++++++++ app/models/show_dates.rb | 18 ---------- app/models/venue.rb | 4 +++ 5 files changed, 33 insertions(+), 50 deletions(-) rename app/models/{cli_commands.rb => cli_command.rb} (91%) create mode 100644 app/models/show_date.rb delete mode 100644 app/models/show_dates.rb diff --git a/app/models/artist.rb b/app/models/artist.rb index 0f973767..420246ff 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -7,40 +7,15 @@ def self.find_or_create_me(username) username = self.find_or_create_by(name:username) end + + #THIS METHOD WORKS(KEEP) def all_my_venues - ShowDate.all.map do |show_instance| - show_instance.venue - end + all_shows = ShowDate.all.select{|show_instance| show_instance.artist == self} + all_shows.map{|show_instance| show_instance.venue.name} #maybe put .uniq on the end end + - # def create_date_for_artist - # ShowDate.find_or_create_by(date: datetime) - # binding.pry - # end - - #helper function to get primary key ID - # def self.all_venue_id - # artist_id_array = ShowDate.ids - # end - - # def self.show_venue_name(username) - # artist_venue = [] - # ShowDate.all.select do |info| - # #binding.pry - # if info.artist.name == username - # return info.venue.name - # else - # return "please create an account" - # end - # end - # end - - # def delete_myself(username) - # if username == self - # self - # end - end #technically the user model diff --git a/app/models/cli_commands.rb b/app/models/cli_command.rb similarity index 91% rename from app/models/cli_commands.rb rename to app/models/cli_command.rb index 50affbef..fd260d91 100644 --- a/app/models/cli_commands.rb +++ b/app/models/cli_command.rb @@ -25,8 +25,8 @@ def create_account def create_a_show puts "Where would you like to play?" user_input = gets.chomp - new_show = ShowDate.create - puts "Your date is" + # new_show = ShowDate.create(Time.now, + # #puts "Your date is" return new_show end diff --git a/app/models/show_date.rb b/app/models/show_date.rb new file mode 100644 index 00000000..531bed2c --- /dev/null +++ b/app/models/show_date.rb @@ -0,0 +1,22 @@ +class ShowDate < ActiveRecord::Base + belongs_to :artist + belongs_to :venue +end + +#Create Method +def self.create_new_date(year, month, date, venue_choice, artist_id) + self.create(date: DateTime.new(year, month, date), venue_id: venue_choice, artist_id: artist_id) + binding.pry +end + +def tester + puts "lol" +end + + + + + + + +#full CRUD \ No newline at end of file diff --git a/app/models/show_dates.rb b/app/models/show_dates.rb deleted file mode 100644 index 0e56f51e..00000000 --- a/app/models/show_dates.rb +++ /dev/null @@ -1,18 +0,0 @@ -class ShowDate < ActiveRecord::Base - belongs_to :artist - belongs_to :venue -end - -def self.show_or_create(year, month, date) - binding.pry - self.find_or_create_by(date: Time.now(year, month, date)) -end - -def self.test - puts "helo" -end - - - - -#full CRUD \ No newline at end of file diff --git a/app/models/venue.rb b/app/models/venue.rb index a42916ae..663e930d 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -5,4 +5,8 @@ class Venue < ActiveRecord::Base def self.get_cities self.all.map{|venue_instance| venue_instance.city}.uniq end + + def update_my_venue + + end end \ No newline at end of file From 071e50dbae11638358f8164aa27882c166a047d3 Mon Sep 17 00:00:00 2001 From: dangnhon Date: Fri, 4 Dec 2020 22:44:49 -0800 Subject: [PATCH 07/19] shoutout to Dain --- app/models/artist.rb | 18 ++--- app/models/cli_command.rb | 72 ++++++++++++++----- app/models/show_date.rb | 14 ---- app/models/venue.rb | 8 +-- bin/run.rb | 42 ++++++----- db/migrate/20201203175042_create_show_date.rb | 2 +- db/schema.rb | 2 +- db/seeds.rb | 30 +++----- 8 files changed, 99 insertions(+), 89 deletions(-) diff --git a/app/models/artist.rb b/app/models/artist.rb index 420246ff..59efe963 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -2,17 +2,17 @@ class Artist < ActiveRecord::Base has_many :show_dates has_many :venues, through: :show_dates - #THIS CREATE METHOD WORKS(KEEP) - def self.find_or_create_me(username) - username = self.find_or_create_by(name:username) - end + # #THIS CREATE METHOD WORKS(KEEP) + # def self.find_or_create_me(username) + # username = self.find_or_create_by(name:username) + # end - #THIS METHOD WORKS(KEEP) - def all_my_venues - all_shows = ShowDate.all.select{|show_instance| show_instance.artist == self} - all_shows.map{|show_instance| show_instance.venue.name} #maybe put .uniq on the end - end + # #THIS METHOD WORKS(KEEP) + # def all_my_venues + # all_shows = ShowDate.all.select{|show_instance| show_instance.artist == self} + # all_shows.map{|show_instance| show_instance.venue.name} #maybe put .uniq on the end + # end diff --git a/app/models/cli_command.rb b/app/models/cli_command.rb index fd260d91..00f5d491 100644 --- a/app/models/cli_command.rb +++ b/app/models/cli_command.rb @@ -1,35 +1,69 @@ def main_menu - puts "What would you like to do?" - puts "1. list cities" - puts "2. create account" - puts "3. create a show" - puts "4. delete my show" - puts "5. exit" - user_input = gets.chomp + puts "Please enter your artist name" + puts "1. list Venue cities" + puts "2. create a show" + #puts "3. update a show" + #puts "4. delete a show" + puts "type 'exit' to leave Artist Tracker" end def list_all_cities - all_cities = Venue.get_cities - all_cities.each_with_index{|city, index| puts "#{index + 1}. #{city}"} + index = 0 + Venue.all.each{|venue| puts "#{index += 1}. #{venue.city}"} end def create_account - puts "Type in your band name" + print "Type in your band name: " user_input = gets.chomp - new_account = Artist.find_or_create_me(user_input) + new_account = Artist.find_or_create_by(name: user_input) puts "Welcome #{user_input}" - return new_account + new_account end -def create_a_show - puts "Where would you like to play?" - user_input = gets.chomp - # new_show = ShowDate.create(Time.now, - # #puts "Your date is" - return new_show +def city_venue(city) + all_venue_cities = Venue.all.select{|venue| venue.city == city} + all_venue_cities.each{|venue| puts "#{venue.name}"} +end + +#CREATE +def create_a_show(artist) + print "When and where would you like to play? Please use format 'YYYY-MM-DD': " + date = gets.chomp + print "What city would you like to play in?: " + list_all_cities + city = gets.chomp + city_venue(city) + print "Which of these Venues would you like to play at?: " + venue = gets.chomp + selected_venue = Venue.find_by(name: venue) + new_show_date = ShowDate.create() + new_show_date.date = date + new_show_date.artist_id = artist.id + new_show_date.venue_id = selected_venue.id + new_show_date.save + puts "Congratualtions! Your show date is #{date}, at #{venue} in #{city}." end + +#READ +def show_all_my_show(artist) + all_show_dates = ShowDate.all.select{|show_date| show_date.artist_id == artist.id}.map{|showdate| showdate.date} + puts all_show_dates +end + def ask_for_new_input puts "That was not a valid input, please try again" -end \ No newline at end of file +end + +#FOR UPDATE METHOD, ONLY LET THEM UPDATE THE DATE OF THEIR SHOW +#1. Have find all of their personal dates for their shows +#2. Then you ask them which one to update by date using 'print and chomp' +#3. Find that instance by date they gave and store that instance as a variable +#4. call .update on that variable(instance) to change their date to whatever they gave. + +#FOR DELETE METHOD, ONLY LET THEM DELETE THE DATE OF THEIR SHOW +#1. Have find all of their personal dates for their shows +#2. Then you ask them which one to delete by date using 'print and chomp' +#3. Find that instance by date they gave and store that instance as a variable +#4. call .destroy on that variable(instance) to change their date to whatever they gave. \ No newline at end of file diff --git a/app/models/show_date.rb b/app/models/show_date.rb index 531bed2c..ea754f89 100644 --- a/app/models/show_date.rb +++ b/app/models/show_date.rb @@ -3,20 +3,6 @@ class ShowDate < ActiveRecord::Base belongs_to :venue end -#Create Method -def self.create_new_date(year, month, date, venue_choice, artist_id) - self.create(date: DateTime.new(year, month, date), venue_id: venue_choice, artist_id: artist_id) - binding.pry -end - -def tester - puts "lol" -end - - - - - #full CRUD \ No newline at end of file diff --git a/app/models/venue.rb b/app/models/venue.rb index 663e930d..3c78f16b 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -2,11 +2,5 @@ class Venue < ActiveRecord::Base has_many :show_dates has_many :artists, through: :show_dates - def self.get_cities - self.all.map{|venue_instance| venue_instance.city}.uniq - end - - def update_my_venue - - end + end \ No newline at end of file diff --git a/bin/run.rb b/bin/run.rb index b46db3a5..deb8cd0e 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -1,28 +1,32 @@ #require_relative '../config/cli_commands' require_relative '../config/environment' -user_selection = "main menu" +#ALL VENUE INSTANCES HAVE TO BE PRELOADED AND THEY ARE STATIC -puts `clear` +puts `clear` puts "Welcome to our Artist App Tracker!" -artist = nil -while true do - case user_selection - when "main menu" - user_selection = main_menu - when "list cities" +print "please enter username: " +artist_name = gets.chomp +artist = Artist.find_or_create_by(name: artist_name) + +input = "begin" +while input != "exit" do + print "What would you like to do(type 'menu' for menu: " + input = gets.chomp + case input + when "menu" + main_menu + when "list Venue cities" list_all_cities - user_selection = "main menu" - when "create account" - artist = create_account - user_selection = "Welcome!" - when "Welcome!" - create_a_show - #user_selection = "something" - when "exit" - break + when "create a show" + create_a_show(artist) + #when "update a show" + #call some update method + #when "delete a show" + #call some delete method + when "exit" + break else - ask_for_new_input - user_selection = "main menu" + puts "This is an unknown command, please try again." end end diff --git a/db/migrate/20201203175042_create_show_date.rb b/db/migrate/20201203175042_create_show_date.rb index 915ce559..0da06587 100644 --- a/db/migrate/20201203175042_create_show_date.rb +++ b/db/migrate/20201203175042_create_show_date.rb @@ -1,7 +1,7 @@ class CreateShowDate < ActiveRecord::Migration[6.0] def change create_table :show_dates do |t| - t.datetime :date + t.string :date t.integer :venue_id t.integer :artist_id end diff --git a/db/schema.rb b/db/schema.rb index 37fabb4f..b0332ce7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -17,7 +17,7 @@ end create_table "show_dates", force: :cascade do |t| - t.datetime "date" + t.string "date" t.integer "venue_id" t.integer "artist_id" end diff --git a/db/seeds.rb b/db/seeds.rb index f86abe3d..b261529d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -11,28 +11,20 @@ ShowDate.destroy_all Venue.destroy_all -# drake = Artist.create(name: "drake") -# slim = Artist.create(name: "slim") -# nas = Artist.create(name: "nas") - -# v1 = Venue.create(name: "Tuscaloosa Ampitheater", city: "Tuscaloosa", state: "Alabama") -# v2 = Venue.create(name: "The Greek", city: "Los Angeles", state: "California") -# v3 = Venue.create(name: "The Gorge Ampitheater", city: "George", state: "Washington") - -# sd1 = ShowDate.create(date:Faker::Date.backward(days: 19000), venue_id: Venue.all.sample.id, artist_id: Artist.all.sample.id) -# sd2 = ShowDate.create(date:Faker::Date.backward(days: 19000), venue_id: Venue.all.sample.id, artist_id: Artist.all.sample.id) -# sd3 = ShowDate.create(date:Faker::Date.backward(days: 19000), venue_id: Venue.all.sample.id, artist_id: Artist.all.sample.id) -15.times do - Artist.create(name:Faker::Music.band) -end -puts 'done' + + + +# 15.times do +# Artist.create(name:Faker::Music.band) +# end +# puts 'done' 15.times do Venue.create(name:Faker::GreekPhilosophers.name, city:Faker::Address.city, state:Faker::Address.state) end puts 'done' -15.times do - ShowDate.create(date:Faker::Date.backward(days: 19000), venue_id: Venue.all.sample.id, artist_id: Artist.all.sample.id) -end -puts 'done' \ No newline at end of file +# 15.times do +# ShowDate.create(date:Faker::Date.forward(days: 23), venue_id: Venue.all.sample.id, artist_id: Artist.all.sample.id) +# end +# puts 'done' \ No newline at end of file From 51dbe292c3ed010fd10544078de4597c20bea635 Mon Sep 17 00:00:00 2001 From: dangnhon Date: Sat, 5 Dec 2020 18:17:55 -0800 Subject: [PATCH 08/19] Almost there --- README.md | 39 +++++++++++-- app/models/artist.rb | 18 +----- app/models/cli_command.rb | 116 +++++++++++++++++++++++++++----------- app/models/show_date.rb | 2 - app/models/venue.rb | 2 - bin/run.rb | 29 +++++++--- config/environment.rb | 4 +- db/seeds.rb | 7 --- 8 files changed, 141 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 413d03a7..ecf95ba3 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,38 @@ -# As a user, I would like to: - +# As a user of our application, an artist can do a few things: + 1. Create a profile/account if they do not have one. + 2. Create a date for a venue location to perform. + 3. View all of their current dates and matching venues. + 4. Update any existing venue dates. + 5. Delete any existing concert or venue dates. + +# Symbols throughout the README: + 1. "" ==> What is displayed in the application terminal. + 2. '' ==> What to type into the terminal (excluding the ''). + +# How to use our application: + 1. Please type in 'bundle install' and then 'bundle update' within the terminal. Next type in 'rake db:seed' in the terminal to generate the venue seed. + + 2. To start the application, type into the terminal 'ruby bin/rb' + + 3. Following the prompts, simply type in your artist name and the application will look for your profile in the database. If it exists, it will pull up your profile, otherwise, your profile will be created. + + 4. To access the menu, type in 'menu' + + 5. Our program is based on key typing selection. To access any of the listed options, please follow the prompts and type in your choice excluding the numbered list ("1."). + + 6. For example, if you choose the option "show my dates" within the menu, type in 'show my dates' and more prompts will follow. + + 7. Each time an option has been completed, you will automatically be return to the main menu. + + 8. A brief video demonstration will be linked here as well: + diff --git a/app/models/artist.rb b/app/models/artist.rb index 59efe963..a0016a36 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -1,23 +1,7 @@ class Artist < ActiveRecord::Base has_many :show_dates has_many :venues, through: :show_dates - - # #THIS CREATE METHOD WORKS(KEEP) - # def self.find_or_create_me(username) - # username = self.find_or_create_by(name:username) - # end - - - # #THIS METHOD WORKS(KEEP) - # def all_my_venues - # all_shows = ShowDate.all.select{|show_instance| show_instance.artist == self} - # all_shows.map{|show_instance| show_instance.venue.name} #maybe put .uniq on the end - # end - - - end -#technically the user model +#The user model -#Artist concert tracker program \ No newline at end of file diff --git a/app/models/cli_command.rb b/app/models/cli_command.rb index 00f5d491..fd1e0a5b 100644 --- a/app/models/cli_command.rb +++ b/app/models/cli_command.rb @@ -1,41 +1,61 @@ + def main_menu - puts "Please enter your artist name" - puts "1. list Venue cities" + puts "Please type in your selection" + puts "1. list venue cities" puts "2. create a show" - #puts "3. update a show" - #puts "4. delete a show" - puts "type 'exit' to leave Artist Tracker" -end - - -def list_all_cities - index = 0 - Venue.all.each{|venue| puts "#{index += 1}. #{venue.city}"} + puts "3. show my dates" + puts "3. update a show date" + puts "4. delete a show" + puts "6. Type 'exit' to leave Artist Tracker" end +# Sign in or create account for Artist method def create_account print "Type in your band name: " user_input = gets.chomp new_account = Artist.find_or_create_by(name: user_input) puts "Welcome #{user_input}" new_account +end + +#HELPER METHOD for listing all available cities +def list_all_cities + index = 0 + Venue.all.each{|venue| puts "#{index += 1}. #{venue.city}"} end + +#HELPER METHOD for listing Venue names of their respective cities def city_venue(city) all_venue_cities = Venue.all.select{|venue| venue.city == city} all_venue_cities.each{|venue| puts "#{venue.name}"} end -#CREATE + +#HELPER METHOD for showing artists existing dates +def dates_of_shows_helper_method(artist) + ShowDate.all.select{|show_date| show_date.artist_id == artist.id}.map{|showdate| showdate.date} +end + +#HELPER METHOD for showing artists existing venues +def venues_of_shows_helper_method(artist) + ShowDate.all.select{|show_date| show_date.artist_id == artist.id}.map{|showdate| showdate.venue.name} +end + + +#CREATE ShowDate method def create_a_show(artist) - print "When and where would you like to play? Please use format 'YYYY-MM-DD': " + puts "When and where would you like to play? Please use format 'YYYY-MM-DD': " date = gets.chomp - print "What city would you like to play in?: " + puts `clear` + puts "What city would you like to play in?: " list_all_cities - city = gets.chomp - city_venue(city) - print "Which of these Venues would you like to play at?: " + city = gets.chomp + puts `clear` + puts "Which of these Venues would you like to play at?: " + city_venue(city) venue = gets.chomp + puts `clear` selected_venue = Venue.find_by(name: venue) new_show_date = ShowDate.create() new_show_date.date = date @@ -46,24 +66,54 @@ def create_a_show(artist) end -#READ +#READ ShowDate method def show_all_my_show(artist) - all_show_dates = ShowDate.all.select{|show_date| show_date.artist_id == artist.id}.map{|showdate| showdate.date} - puts all_show_dates + all_show_dates = dates_of_shows_helper_method(artist) + all_venue_names = venues_of_shows_helper_method(artist) + if all_show_dates == [] && all_venue_names == [] + puts "Sorry, you currently do not have any dates listed for a venue. Please create a show." + else puts "You will be playing on the date #{all_show_dates.uniq.join(', ')} at #{all_venue_names.uniq.join(', ')}." + end +end + + +# UPDATE ShowDate method +def update_my_show(artist) + puts "Here is a list of your Venue dates. Please type in the date you would like to change: " + puts "- #{dates_of_shows_helper_method(artist).join(", ")}" + date_selected = gets.chomp + puts `clear` + print "Please enter your new desired date in the format 'YYYY-MM-DD': " + new_date = gets.chomp + puts `clear` + change_date = ShowDate.all.find_by(artist_id: artist.id) + set_date = change_date.update(date: new_date) + puts "Congratulations, your Venue date is now updated to #{new_date}!" end -def ask_for_new_input - puts "That was not a valid input, please try again" + +#DELETE ShowDate method +def delete_my_show(artist) + puts "Here are your Venue dates. Please type in the date you would like to cancel and delete: " + puts "- #{dates_of_shows_helper_method(artist).uniq.join(", ")}" + date_selected = gets.chomp + delete_date = ShowDate.all.find_by(artist_id: artist.id) + delete_date.destroy + puts "Congratulations, your selected venue date has been successfully cancelled." end -#FOR UPDATE METHOD, ONLY LET THEM UPDATE THE DATE OF THEIR SHOW -#1. Have find all of their personal dates for their shows -#2. Then you ask them which one to update by date using 'print and chomp' -#3. Find that instance by date they gave and store that instance as a variable -#4. call .update on that variable(instance) to change their date to whatever they gave. - -#FOR DELETE METHOD, ONLY LET THEM DELETE THE DATE OF THEIR SHOW -#1. Have find all of their personal dates for their shows -#2. Then you ask them which one to delete by date using 'print and chomp' -#3. Find that instance by date they gave and store that instance as a variable -#4. call .destroy on that variable(instance) to change their date to whatever they gave. \ No newline at end of file + +#Tried to implement return option: +# def return_to_menu +# input = "begin" +# while input != "return" do +# print "Type 'return' to go back to menu: " +# input = gets.chomp +# case input +# when "return" +# break +# end +# end +# end + + diff --git a/app/models/show_date.rb b/app/models/show_date.rb index ea754f89..583cad8d 100644 --- a/app/models/show_date.rb +++ b/app/models/show_date.rb @@ -3,6 +3,4 @@ class ShowDate < ActiveRecord::Base belongs_to :venue end - - #full CRUD \ No newline at end of file diff --git a/app/models/venue.rb b/app/models/venue.rb index 3c78f16b..f060f065 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -1,6 +1,4 @@ class Venue < ActiveRecord::Base has_many :show_dates has_many :artists, through: :show_dates - - end \ No newline at end of file diff --git a/bin/run.rb b/bin/run.rb index deb8cd0e..6e30b42d 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -1,32 +1,43 @@ -#require_relative '../config/cli_commands' require_relative '../config/environment' -#ALL VENUE INSTANCES HAVE TO BE PRELOADED AND THEY ARE STATIC +#ALL VENUE INSTANCES HAVE TO BE PRELOADED +#Assume Venues already exist in the database puts `clear` puts "Welcome to our Artist App Tracker!" print "please enter username: " artist_name = gets.chomp artist = Artist.find_or_create_by(name: artist_name) +puts `clear` + input = "begin" while input != "exit" do - print "What would you like to do(type 'menu' for menu: " + print "Please type 'menu' for menu: " input = gets.chomp case input when "menu" + puts `clear` main_menu - when "list Venue cities" + when "list venue cities" + puts `clear` list_all_cities when "create a show" + puts `clear` create_a_show(artist) - #when "update a show" - #call some update method - #when "delete a show" - #call some delete method + when "show my dates" + puts `clear` + show_all_my_show(artist) + when "update a show date" + puts `clear` + update_my_show(artist) + when "delete a show" + puts `clear` + delete_my_show(artist) when "exit" break else - puts "This is an unknown command, please try again." + puts `clear` + puts "This is an unknown command, please try again." end end diff --git a/config/environment.rb b/config/environment.rb index 5bd47fdd..7005649c 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -3,4 +3,6 @@ require_all 'app/models' -ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') \ No newline at end of file +ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') + +ActiveRecord::Base.logger = nil \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index b261529d..1394a9ef 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,12 +1,5 @@ require 'faker' -#key = KA7HJvpLeeJHtp4Y2SkcGVzOmw9AAmJ1 -#https://app.ticketmaster.com/discovery/v2/venues.json?apikey=KA7HJvpLeeJHtp4Y2SkcGVzOmw9AAmJ1 -# if you want keyword searchability, add &keyword=#{interpolated_passed_here} to the end of apikey in the url - -# in config/environment.rb add this line: -# ActiveRecord::Base.logger = nil - Artist.destroy_all ShowDate.destroy_all Venue.destroy_all From a26bbb78ccfefb7ec8b84bb279447a14204c4727 Mon Sep 17 00:00:00 2001 From: dangnhon Date: Sat, 5 Dec 2020 20:38:43 -0800 Subject: [PATCH 09/19] fixed a menu --- app/models/cli_command.rb | 4 ++-- app/models/venue.rb | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/cli_command.rb b/app/models/cli_command.rb index fd1e0a5b..89bf3811 100644 --- a/app/models/cli_command.rb +++ b/app/models/cli_command.rb @@ -4,8 +4,8 @@ def main_menu puts "1. list venue cities" puts "2. create a show" puts "3. show my dates" - puts "3. update a show date" - puts "4. delete a show" + puts "4. update a show date" + puts "5. delete a show" puts "6. Type 'exit' to leave Artist Tracker" end diff --git a/app/models/venue.rb b/app/models/venue.rb index f060f065..1125d9cf 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -1,4 +1,6 @@ class Venue < ActiveRecord::Base has_many :show_dates has_many :artists, through: :show_dates -end \ No newline at end of file +end + + From 9d57a223dafa52225486801c2f260ce2684562fd Mon Sep 17 00:00:00 2001 From: Hunter Posey Date: Mon, 7 Dec 2020 10:53:19 -0800 Subject: [PATCH 10/19] minor tweaks and changes to interface. Final Product --- README.md | 2 +- Rakefile | 2 +- app/models/artist.rb | 5 +- app/models/cli_command.rb | 80 +++++++++++-------- app/models/show_date.rb | 4 +- app/models/venue.rb | 4 +- bin/run.rb | 26 +++--- db/migrate/20201203003537_create_artist.rb | 2 +- db/migrate/20201203003625_create_venue.rb | 2 +- db/migrate/20201203175042_create_show_date.rb | 2 +- db/schema.rb | 3 +- db/seeds.rb | 5 +- 12 files changed, 68 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index ecf95ba3..f46534b7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Symbols throughout the README: 1. "" ==> What is displayed in the application terminal - 2. '' ==> WHat to type into the terminal (excluding the '') + 2. '' ==> What to type into the terminal (excluding the '') # Goal: The goal of our CLI application is to be a simple tool for Artists and allows venue and concert date tracking. This is implementing a user built database with venue locations already pre-seeded. diff --git a/Rakefile b/Rakefile index 508ef20e..95def954 100644 --- a/Rakefile +++ b/Rakefile @@ -5,4 +5,4 @@ desc 'starts a console' task :console do ActiveRecord::Base.logger = Logger.new(STDOUT) Pry.start -end +end \ No newline at end of file diff --git a/app/models/artist.rb b/app/models/artist.rb index a0016a36..3c669a03 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -1,7 +1,4 @@ class Artist < ActiveRecord::Base has_many :show_dates has_many :venues, through: :show_dates -end - -#The user model - +end \ No newline at end of file diff --git a/app/models/cli_command.rb b/app/models/cli_command.rb index 89bf3811..ae708bf7 100644 --- a/app/models/cli_command.rb +++ b/app/models/cli_command.rb @@ -1,20 +1,19 @@ - def main_menu - puts "Please type in your selection" - puts "1. list venue cities" - puts "2. create a show" - puts "3. show my dates" - puts "4. update a show date" - puts "5. delete a show" - puts "6. Type 'exit' to leave Artist Tracker" + puts "Please type in your selection\n\n" + puts "1. City List" + puts "2. Create Show" + puts "3. Upcoming or Past Dates" + puts "4. Update Existing Show" + puts "5. Delete Existing Show" + puts "6. Type 'Exit' to leave the Artist Event Scheduler" end # Sign in or create account for Artist method def create_account - print "Type in your band name: " + print "Whats your Artist/Band name?: " user_input = gets.chomp new_account = Artist.find_or_create_by(name: user_input) - puts "Welcome #{user_input}" + puts "Welcome, #{user_input}!" new_account end @@ -23,15 +22,13 @@ def list_all_cities index = 0 Venue.all.each{|venue| puts "#{index += 1}. #{venue.city}"} end - #HELPER METHOD for listing Venue names of their respective cities def city_venue(city) all_venue_cities = Venue.all.select{|venue| venue.city == city} - all_venue_cities.each{|venue| puts "#{venue.name}"} + all_venue_cities.each{|venue| puts "-#{venue.name}"} end - #HELPER METHOD for showing artists existing dates def dates_of_shows_helper_method(artist) ShowDate.all.select{|show_date| show_date.artist_id == artist.id}.map{|showdate| showdate.date} @@ -42,18 +39,19 @@ def venues_of_shows_helper_method(artist) ShowDate.all.select{|show_date| show_date.artist_id == artist.id}.map{|showdate| showdate.venue.name} end - #CREATE ShowDate method def create_a_show(artist) - puts "When and where would you like to play? Please use format 'YYYY-MM-DD': " + puts "When is your show? (MM-DD-YYY): \n\n" #Could use any format, but for designer purposes. date = gets.chomp puts `clear` - puts "What city would you like to play in?: " + puts "What city is your show in?: \n\n" list_all_cities + puts "\n" city = gets.chomp puts `clear` - puts "Which of these Venues would you like to play at?: " + puts "Choose a venue!: \n\n" city_venue(city) + puts "\n" venue = gets.chomp puts `clear` selected_venue = Venue.find_by(name: venue) @@ -62,47 +60,61 @@ def create_a_show(artist) new_show_date.artist_id = artist.id new_show_date.venue_id = selected_venue.id new_show_date.save - puts "Congratualtions! Your show date is #{date}, at #{venue} in #{city}." + puts "Congratulations! Your show date is #{date}, at #{venue} in #{city}!\n\n" end - #READ ShowDate method def show_all_my_show(artist) all_show_dates = dates_of_shows_helper_method(artist) all_venue_names = venues_of_shows_helper_method(artist) if all_show_dates == [] && all_venue_names == [] - puts "Sorry, you currently do not have any dates listed for a venue. Please create a show." - else puts "You will be playing on the date #{all_show_dates.uniq.join(', ')} at #{all_venue_names.uniq.join(', ')}." + puts "Oh no! Looks like you don't have any dates yet! Go back to the menu to create one!\n\n" + else puts "You have a show on #{all_show_dates.uniq.join(', ')} at #{all_venue_names.uniq.join(', ')}!\n\n" end end - # UPDATE ShowDate method def update_my_show(artist) - puts "Here is a list of your Venue dates. Please type in the date you would like to change: " - puts "- #{dates_of_shows_helper_method(artist).join(", ")}" + puts "Here is a list of your shows! Please type in the date you would like to change: \n\n" + puts "- #{dates_of_shows_helper_method(artist).join(", ")} at #{venues_of_shows_helper_method(artist).uniq.join(', ')}.\n\n" date_selected = gets.chomp puts `clear` - print "Please enter your new desired date in the format 'YYYY-MM-DD': " + puts "Choose a city for the updated show: \n\n" + list_all_cities + puts "\n" + city_selected = gets.chomp + puts `clear` + puts "Choose the venue: \n\n" + city_venue(city_selected) + puts "\n" + puts "Selected Venue: \n" + venue_selected = gets.chomp + puts "\n" + puts `clear` + print "Please enter your new desired date in the format 'MM-DD-YYYY': \n\n" new_date = gets.chomp puts `clear` change_date = ShowDate.all.find_by(artist_id: artist.id) + change_city = Venue.all.find_by(city: city_selected) + change_venue = Venue.all.find_by(name: venue_selected) set_date = change_date.update(date: new_date) - puts "Congratulations, your Venue date is now updated to #{new_date}!" + set_city = change_city.update(city: city_selected) + set_venue = change_venue.update(name: venue_selected) + puts "Congratulations! Your Show for that date is now updated to #{new_date} in #{city_selected} at #{venue_selected}!\n\n" end - #DELETE ShowDate method def delete_my_show(artist) - puts "Here are your Venue dates. Please type in the date you would like to cancel and delete: " - puts "- #{dates_of_shows_helper_method(artist).uniq.join(", ")}" + puts "Here are your shows! Please type in the date you would like to cancel and delete: \n\n" + puts "- #{dates_of_shows_helper_method(artist).uniq.join(", ")}\n\n" + puts "Selected Date: " date_selected = gets.chomp delete_date = ShowDate.all.find_by(artist_id: artist.id) - delete_date.destroy - puts "Congratulations, your selected venue date has been successfully cancelled." + delete_date.destroy + puts "\n" + puts "Congratulations! Your selected show has been successfully cancelled!\n\n" end - #Tried to implement return option: # def return_to_menu # input = "begin" @@ -114,6 +126,4 @@ def delete_my_show(artist) # break # end # end -# end - - +# end \ No newline at end of file diff --git a/app/models/show_date.rb b/app/models/show_date.rb index 583cad8d..11c9761a 100644 --- a/app/models/show_date.rb +++ b/app/models/show_date.rb @@ -1,6 +1,4 @@ class ShowDate < ActiveRecord::Base belongs_to :artist belongs_to :venue -end - -#full CRUD \ No newline at end of file +end \ No newline at end of file diff --git a/app/models/venue.rb b/app/models/venue.rb index 1125d9cf..f060f065 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -1,6 +1,4 @@ class Venue < ActiveRecord::Base has_many :show_dates has_many :artists, through: :show_dates -end - - +end \ No newline at end of file diff --git a/bin/run.rb b/bin/run.rb index 6e30b42d..b66e7feb 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -3,41 +3,41 @@ #ALL VENUE INSTANCES HAVE TO BE PRELOADED #Assume Venues already exist in the database -puts `clear` -puts "Welcome to our Artist App Tracker!" -print "please enter username: " +puts `clear` +puts "BETA Build" +puts "\n\n\nHello, and welcome to the Artist Event Scheduler!\n\n\n\n" +print "Please enter your Artist/Band Name: " artist_name = gets.chomp artist = Artist.find_or_create_by(name: artist_name) puts `clear` - input = "begin" while input != "exit" do - print "Please type 'menu' for menu: " + print "\n\nPlease type 'menu' to see your list of available actions: " input = gets.chomp case input - when "menu" + when "MENU".downcase puts `clear` main_menu - when "list venue cities" + when "CITY LIST".downcase puts `clear` list_all_cities - when "create a show" + when "CREATE SHOW".downcase puts `clear` create_a_show(artist) - when "show my dates" + when "UPCOMING OR PAST DATES".downcase puts `clear` show_all_my_show(artist) - when "update a show date" + when "UPDATE EXISTING SHOW".downcase puts `clear` update_my_show(artist) - when "delete a show" + when "DELETE EXISTING SHOW".downcase puts `clear` delete_my_show(artist) - when "exit" + when "EXIT".downcase break else puts `clear` - puts "This is an unknown command, please try again." + puts "This is an UNKNOWN command, please try again!" end end diff --git a/db/migrate/20201203003537_create_artist.rb b/db/migrate/20201203003537_create_artist.rb index fa459d7f..f7b22e55 100644 --- a/db/migrate/20201203003537_create_artist.rb +++ b/db/migrate/20201203003537_create_artist.rb @@ -4,4 +4,4 @@ def change t.string :name end end -end +end \ No newline at end of file diff --git a/db/migrate/20201203003625_create_venue.rb b/db/migrate/20201203003625_create_venue.rb index af4c092e..5f3eb765 100644 --- a/db/migrate/20201203003625_create_venue.rb +++ b/db/migrate/20201203003625_create_venue.rb @@ -6,4 +6,4 @@ def change t.string :state end end -end +end \ No newline at end of file diff --git a/db/migrate/20201203175042_create_show_date.rb b/db/migrate/20201203175042_create_show_date.rb index 0da06587..f2f565a0 100644 --- a/db/migrate/20201203175042_create_show_date.rb +++ b/db/migrate/20201203175042_create_show_date.rb @@ -6,4 +6,4 @@ def change t.integer :artist_id end end -end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index b0332ce7..e0ef0644 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -27,5 +27,4 @@ t.string "city" t.string "state" end - -end +end \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index 1394a9ef..1df4eeb5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,15 +4,12 @@ ShowDate.destroy_all Venue.destroy_all - - - # 15.times do # Artist.create(name:Faker::Music.band) # end # puts 'done' -15.times do +100.times do Venue.create(name:Faker::GreekPhilosophers.name, city:Faker::Address.city, state:Faker::Address.state) end puts 'done' From 0c61983fc8a79288e2830be8a673e201eeb19d8e Mon Sep 17 00:00:00 2001 From: dangnhon Date: Mon, 7 Dec 2020 11:07:53 -0800 Subject: [PATCH 11/19] please delete comment in artist line 6 --- app/models/artist.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/artist.rb b/app/models/artist.rb index 3c669a03..de0868f1 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -1,4 +1,6 @@ class Artist < ActiveRecord::Base has_many :show_dates has_many :venues, through: :show_dates -end \ No newline at end of file +end + +#This is to test our git branch push and pulls. please delete if you can pull this, Hunter. \ No newline at end of file From 525f613e25f71bcabef0851f1b270933da55a0a3 Mon Sep 17 00:00:00 2001 From: Hunter Posey Date: Mon, 7 Dec 2020 11:17:58 -0800 Subject: [PATCH 12/19] Deleted Comment on artist class, line 6 --- app/models/artist.rb | 4 +--- bin/run.rb | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/models/artist.rb b/app/models/artist.rb index de0868f1..3c669a03 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -1,6 +1,4 @@ class Artist < ActiveRecord::Base has_many :show_dates has_many :venues, through: :show_dates -end - -#This is to test our git branch push and pulls. please delete if you can pull this, Hunter. \ No newline at end of file +end \ No newline at end of file diff --git a/bin/run.rb b/bin/run.rb index b66e7feb..ca85ddee 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -40,4 +40,4 @@ puts `clear` puts "This is an UNKNOWN command, please try again!" end -end +end \ No newline at end of file From aaff2ae1247394f2a17027dd4c9693a206b7fd66 Mon Sep 17 00:00:00 2001 From: Hunter Posey Date: Mon, 7 Dec 2020 11:54:48 -0800 Subject: [PATCH 13/19] deleted unused state column and FAKER data --- README.md | 4 +--- db/migrate/20201203003625_create_venue.rb | 1 - db/schema.rb | 4 ++-- db/seeds.rb | 12 ++++++------ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f46534b7..fb335908 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,4 @@ 7. Each time an option has been completed, you will automatically be return to the main menu. - 8. A brief video demonstration will be linked here as well: - - + 8. A brief video demonstration will be linked here as well: \ No newline at end of file diff --git a/db/migrate/20201203003625_create_venue.rb b/db/migrate/20201203003625_create_venue.rb index 5f3eb765..8151f1ac 100644 --- a/db/migrate/20201203003625_create_venue.rb +++ b/db/migrate/20201203003625_create_venue.rb @@ -3,7 +3,6 @@ def change create_table :venues do |t| t.string :name t.string :city - t.string :state end end end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index e0ef0644..d4220af5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -25,6 +25,6 @@ create_table "venues", force: :cascade do |t| t.string "name" t.string "city" - t.string "state" end -end \ No newline at end of file + +end diff --git a/db/seeds.rb b/db/seeds.rb index 1df4eeb5..1296c7fa 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,16 +1,16 @@ require 'faker' -Artist.destroy_all -ShowDate.destroy_all -Venue.destroy_all +#Artist.destroy_all +#ShowDate.destroy_all +#Venue.destroy_all -# 15.times do +# 15.times do # Artist.create(name:Faker::Music.band) # end # puts 'done' -100.times do - Venue.create(name:Faker::GreekPhilosophers.name, city:Faker::Address.city, state:Faker::Address.state) +50.times do + Venue.create(name:Faker::GreekPhilosophers.name, city:Faker::Address.city) #state:Faker::Address.state end puts 'done' From 7bd640bf0c9d44e997eb482e7840bd94b951f8ce Mon Sep 17 00:00:00 2001 From: dangnhon Date: Mon, 7 Dec 2020 13:50:44 -0800 Subject: [PATCH 14/19] edited README file --- README.md | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fb335908..ea74a81f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,18 @@ # Venue and Date Tracker for Artists +# Goal: + The goal of our CLI application is to be a simple tool for Artists and allows venue and concert date tracking. This is implementing a user built database with venue locations already pre-seeded. + # Symbols throughout the README: 1. "" ==> What is displayed in the application terminal 2. '' ==> What to type into the terminal (excluding the '') -# Goal: - The goal of our CLI application is to be a simple tool for Artists and allows venue and concert date tracking. This is implementing a user built database with venue locations already pre-seeded. +# Prerequisites and Installation to Get Started: + 1. Please have the latest version of Ruby and an environment such Visual Studio. + 2. Fork and clone a local copy of this repository into your local machine. + 3. Ensure that all gems have been installed and updated correctly by running 'bundle install' and 'bundle update' in the terminal. + 4. Run 'rake db:migrate' once to create a database for storage. + 5. Run 'rake:db seed' once to have Venues and corresponding locations be pre-loaded into database. # As a user of our application, an artist can do a few things: 1. Create a profile/account if they do not have one. @@ -14,23 +21,21 @@ 4. Update any existing venue dates. 5. Delete any existing concert or venue dates. -# Symbols throughout the README: - 1. "" ==> What is displayed in the application terminal. - 2. '' ==> What to type into the terminal (excluding the ''). - # How to use our application: - 1. Please type in 'bundle install' and then 'bundle update' within the terminal. Next type in 'rake db:seed' in the terminal to generate the venue seed. + 1. To start the application, type into the terminal 'ruby bin/run.rb' + + 2. Following the prompts, simply type in your artist name and the application will look for your profile in the database. If it exists, it will pull up your profile, otherwise, your profile will be created. - 2. To start the application, type into the terminal 'ruby bin/rb' + 3. To access the menu, type in 'menu' - 3. Following the prompts, simply type in your artist name and the application will look for your profile in the database. If it exists, it will pull up your profile, otherwise, your profile will be created. + 4. Our program is based on key typing selection. To access any of the listed options, please follow the prompts and type in your choice excluding any numbered list ("1."). - 4. To access the menu, type in 'menu' + 5. For example, if you choose the option "Upcoming or Past Dates" within the menu, type in 'Upcoming or Past Dates' and more prompts will follow. - 5. Our program is based on key typing selection. To access any of the listed options, please follow the prompts and type in your choice excluding the numbered list ("1."). + NOTE: Menu item selection is not case sensitive. - 6. For example, if you choose the option "show my dates" within the menu, type in 'show my dates' and more prompts will follow. + NOTE: When Selecting inner options, inputs must match what is displayed. EX: Within "Create Show", selecting a city name is case sensistive and has to be a match to what is listed. - 7. Each time an option has been completed, you will automatically be return to the main menu. + 6. Each time an option has been completed, you will automatically be return to the main menu. - 8. A brief video demonstration will be linked here as well: \ No newline at end of file + 7. A brief video demonstration will be linked here as well: \ No newline at end of file From db78854617cadfd701dee35b8680284ca19ef770 Mon Sep 17 00:00:00 2001 From: dangnhon Date: Mon, 7 Dec 2020 13:51:24 -0800 Subject: [PATCH 15/19] Finished README file. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ea74a81f..224116e8 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ # Prerequisites and Installation to Get Started: 1. Please have the latest version of Ruby and an environment such Visual Studio. - 2. Fork and clone a local copy of this repository into your local machine. - 3. Ensure that all gems have been installed and updated correctly by running 'bundle install' and 'bundle update' in the terminal. + 2. Fork and clone a copy of this repository into your local machine. + 3. Ensure that all gems have been installed and updated correctly. This will be done for you by running 'bundle install' and 'bundle update' in the terminal. 4. Run 'rake db:migrate' once to create a database for storage. 5. Run 'rake:db seed' once to have Venues and corresponding locations be pre-loaded into database. From b517e6b4865e3265aa5ec4fa7cf7d55189da7f06 Mon Sep 17 00:00:00 2001 From: Hunter Posey Date: Mon, 7 Dec 2020 14:06:12 -0800 Subject: [PATCH 16/19] fixed typos --- .editorconfig | 2 +- .gitignore | 2 +- CONTRIBUTING.md | 2 +- Gemfile.lock | 2 +- LICENSE.md | 2 +- README.md | 2 +- db/schema.rb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index 6fd332de..5e566598 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,4 +10,4 @@ indent_size = 4 [*.{js,json,rb}] charset = utf-8 -indent_size = 2 +indent_size = 2 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 378d5e08..5d791d6b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ tmp *.log *.swp -db/*.db +db/*.db \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 14b18f92..c7cad8dc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,4 +34,4 @@ We need help from the community of Learners to maintain and improve the educational content. Everything from fixing typos, to correcting out-dated information, to improving exposition, to adding better examples, to fixing tests—all contributions to making the curriculum more effective are -welcome. +welcome. \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index f50eb89f..31a5244d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,4 +62,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 2.1.4 + 2.1.4 \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md index 6802f2b8..ad734fae 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -4,4 +4,4 @@ Copyright (c) 2015 Flatiron School, Inc The Flatiron School, Inc. owns this Educational Content. However, the Flatiron School supports the development and availability of educational materials in the public domain. Therefore, the Flatiron School grants Users of the Flatiron Educational Content set forth in this repository certain rights to reuse, build upon and share such Educational Content subject to the terms of the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). You must read carefully the terms and conditions contained in the Educational Content License as such terms govern access to and use of the Educational Content. -Flatiron School is willing to allow you access to and use of the Educational Content only on the condition that you accept all of the terms and conditions contained in the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). By accessing and/or using the Educational Content, you are agreeing to all of the terms and conditions contained in the Educational Content License. If you do not agree to any or all of the terms of the Educational Content License, you are prohibited from accessing, reviewing or using in any way the Educational Content. +Flatiron School is willing to allow you access to and use of the Educational Content only on the condition that you accept all of the terms and conditions contained in the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). By accessing and/or using the Educational Content, you are agreeing to all of the terms and conditions contained in the Educational Content License. If you do not agree to any or all of the terms of the Educational Content License, you are prohibited from accessing, reviewing or using in any way the Educational Content. \ No newline at end of file diff --git a/README.md b/README.md index 224116e8..30056463 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ 1. "" ==> What is displayed in the application terminal 2. '' ==> What to type into the terminal (excluding the '') -# Prerequisites and Installation to Get Started: +# Prerequisites and installation to get started: 1. Please have the latest version of Ruby and an environment such Visual Studio. 2. Fork and clone a copy of this repository into your local machine. 3. Ensure that all gems have been installed and updated correctly. This will be done for you by running 'bundle install' and 'bundle update' in the terminal. diff --git a/db/schema.rb b/db/schema.rb index d4220af5..ba3f7cd6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -27,4 +27,4 @@ t.string "city" end -end +end \ No newline at end of file From c8489142e2279b775610fe1aad701f1983064118 Mon Sep 17 00:00:00 2001 From: Hunter Posey Date: Mon, 7 Dec 2020 15:37:57 -0800 Subject: [PATCH 17/19] minor tweaks, bug checks --- Gemfile.lock | 16 +++++++++++++++- README.md | 8 ++++---- app/models/cli_command.rb | 11 ++++++----- bin/run.rb | 17 +++++++++-------- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 31a5244d..7bdf2ffb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,8 @@ GEM minitest (5.14.2) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) + pastel (0.8.0) + tty-color (~> 0.5) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -47,8 +49,19 @@ GEM sqlite3 (1.4.2) thread_safe (0.3.6) tilt (2.0.10) + tty-color (0.6.0) + tty-cursor (0.7.1) + tty-prompt (0.22.0) + pastel (~> 0.8) + tty-reader (~> 0.8) + tty-reader (0.8.0) + tty-cursor (~> 0.7) + tty-screen (~> 0.8) + wisper (~> 2.0) + tty-screen (0.8.1) tzinfo (1.2.8) thread_safe (~> 0.1) + wisper (2.0.1) zeitwerk (2.4.2) PLATFORMS @@ -60,6 +73,7 @@ DEPENDENCIES require_all sinatra-activerecord sqlite3 + tty-prompt BUNDLED WITH - 2.1.4 \ No newline at end of file + 2.1.4 diff --git a/README.md b/README.md index 30056463..27ef48ac 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,16 @@ # Goal: The goal of our CLI application is to be a simple tool for Artists and allows venue and concert date tracking. This is implementing a user built database with venue locations already pre-seeded. -# Symbols throughout the README: +# Symbols throughout the README: 1. "" ==> What is displayed in the application terminal 2. '' ==> What to type into the terminal (excluding the '') # Prerequisites and installation to get started: 1. Please have the latest version of Ruby and an environment such Visual Studio. - 2. Fork and clone a copy of this repository into your local machine. - 3. Ensure that all gems have been installed and updated correctly. This will be done for you by running 'bundle install' and 'bundle update' in the terminal. + 2. Fork and clone a copy of this repository into your local machine. + 3. Ensure that all gems have been installed and updated correctly. This will be done for you by running 'bundle install' and 'bundle update' in the terminal. 4. Run 'rake db:migrate' once to create a database for storage. - 5. Run 'rake:db seed' once to have Venues and corresponding locations be pre-loaded into database. + 5. Run 'rake:db seed' once to have Venues and corresponding locations be pre-loaded into database. # As a user of our application, an artist can do a few things: 1. Create a profile/account if they do not have one. diff --git a/app/models/cli_command.rb b/app/models/cli_command.rb index ae708bf7..2b3aa869 100644 --- a/app/models/cli_command.rb +++ b/app/models/cli_command.rb @@ -1,5 +1,6 @@ -def main_menu - puts "Please type in your selection\n\n" +def main_menu + puts `clear` + puts "Please type a number from the list below...\n\n" puts "1. City List" puts "2. Create Show" puts "3. Upcoming or Past Dates" @@ -47,9 +48,9 @@ def create_a_show(artist) puts "What city is your show in?: \n\n" list_all_cities puts "\n" - city = gets.chomp + city = gets.chomp puts `clear` - puts "Choose a venue!: \n\n" + puts "Choose a venue: \n\n" city_venue(city) puts "\n" venue = gets.chomp @@ -112,7 +113,7 @@ def delete_my_show(artist) delete_date = ShowDate.all.find_by(artist_id: artist.id) delete_date.destroy puts "\n" - puts "Congratulations! Your selected show has been successfully cancelled!\n\n" + puts "Congratulations! Your selected show has been successfully deleted!\n\n" end #Tried to implement return option: diff --git a/bin/run.rb b/bin/run.rb index ca85ddee..89bd5946 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -4,7 +4,7 @@ #Assume Venues already exist in the database puts `clear` -puts "BETA Build" +puts "BETA Build v1.0" puts "\n\n\nHello, and welcome to the Artist Event Scheduler!\n\n\n\n" print "Please enter your Artist/Band Name: " artist_name = gets.chomp @@ -13,28 +13,29 @@ input = "begin" while input != "exit" do - print "\n\nPlease type 'menu' to see your list of available actions: " + print "\n\nPlease type '0' to see your list of available actions: " input = gets.chomp case input - when "MENU".downcase + when "0" puts `clear` main_menu - when "CITY LIST".downcase + when "1" puts `clear` list_all_cities - when "CREATE SHOW".downcase + when "2" puts `clear` create_a_show(artist) - when "UPCOMING OR PAST DATES".downcase + when "3" puts `clear` show_all_my_show(artist) - when "UPDATE EXISTING SHOW".downcase + when "4" puts `clear` update_my_show(artist) - when "DELETE EXISTING SHOW".downcase + when "5" puts `clear` delete_my_show(artist) when "EXIT".downcase + puts `clear` break else puts `clear` From f1c2ecdbc71192df209d45bcea51db56cef100a9 Mon Sep 17 00:00:00 2001 From: dangnhon Date: Mon, 7 Dec 2020 16:16:24 -0800 Subject: [PATCH 18/19] updated README to reflect menu changes --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 27ef48ac..c81cead6 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,14 @@ 2. Following the prompts, simply type in your artist name and the application will look for your profile in the database. If it exists, it will pull up your profile, otherwise, your profile will be created. - 3. To access the menu, type in 'menu' + 3. To access the menu, type in '0' - 4. Our program is based on key typing selection. To access any of the listed options, please follow the prompts and type in your choice excluding any numbered list ("1."). + 4. Our program is based on number and key character typing selection. To access any of the listed options in the main menu, please type in your desired number option. - 5. For example, if you choose the option "Upcoming or Past Dates" within the menu, type in 'Upcoming or Past Dates' and more prompts will follow. + 5. For example, if you choose the option "Upcoming or Past Dates" within the menu, type in '3' and more prompts will follow. - NOTE: Menu item selection is not case sensitive. + NOTE: When Selecting inner options, inputs must match what is displayed. EX: Within "Create Show", selecting a city name is case sensistive and has to be a inputted as a match to the list. - NOTE: When Selecting inner options, inputs must match what is displayed. EX: Within "Create Show", selecting a city name is case sensistive and has to be a match to what is listed. - - 6. Each time an option has been completed, you will automatically be return to the main menu. + 6. Each time an option has been completed, you will have to type '0' to return to the main menu. This prompt will viewable as well. 7. A brief video demonstration will be linked here as well: \ No newline at end of file From 38abb494e86c1c88a338f30b77c174c2c7760587 Mon Sep 17 00:00:00 2001 From: Hunter Posey Date: Mon, 7 Dec 2020 16:51:21 -0800 Subject: [PATCH 19/19] FINAL product --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c81cead6..2774262c 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # Venue and Date Tracker for Artists # Goal: - The goal of our CLI application is to be a simple tool for Artists and allows venue and concert date tracking. This is implementing a user built database with venue locations already pre-seeded. + The goal of our CLI application is to be a simple tool for Artists that allows venue and concert date tracking. This is implementing a user built database with venue locations already pre-seeded. # Symbols throughout the README: 1. "" ==> What is displayed in the application terminal 2. '' ==> What to type into the terminal (excluding the '') -# Prerequisites and installation to get started: +# Prerequisites and installation guide to get started: 1. Please have the latest version of Ruby and an environment such Visual Studio. 2. Fork and clone a copy of this repository into your local machine. 3. Ensure that all gems have been installed and updated correctly. This will be done for you by running 'bundle install' and 'bundle update' in the terminal. @@ -32,8 +32,11 @@ 5. For example, if you choose the option "Upcoming or Past Dates" within the menu, type in '3' and more prompts will follow. - NOTE: When Selecting inner options, inputs must match what is displayed. EX: Within "Create Show", selecting a city name is case sensistive and has to be a inputted as a match to the list. + NOTE: When selecting inner options, inputs must match what is displayed. EX: Within "Create Show", selecting a city name is case sensistive and has to be a inputted as a match to the list. 6. Each time an option has been completed, you will have to type '0' to return to the main menu. This prompt will viewable as well. - 7. A brief video demonstration will be linked here as well: \ No newline at end of file + 7. A brief video demonstration is linked below: + + + *https://drive.google.com/file/d/1DrpCUfpq0eow_fq1gSAkgDGylB86Qh0J/view?usp=sharing* \ No newline at end of file