Demian-Wicky / THP_W5D3_ChinookMusic

πŸš€πŸ’― The Hacking Project - Chinook Music 🎸 🎡

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chinook Music db (100% finished)

A Ruby on rails project containing a music database (an Album model and a Track model). The data comes from the db>seeds.rb file.

Table of contents

General info

Made during The Hacking Project course on Week5 Day3.

Technologies

Project is created with

  • Ruby on Rails 5.2.3

Setup

First, go to the RoR project folder and type:

bundle install

then

rails c

Questions

Copy/paste the corresponding commands for each question in the console to display the answer.

😊 Easy level

  • What is the total number of Album objects contained in the database ?

    Album.count
  • Who is the author of the song "White Room"?

    Track.find_by(title: "White Room").artist
  • Which song lasts exactly 188133 milliseconds?

    Track.find_by(duration: 188133).title
  • Which band released the album "Use Your Illusion II" ?

    Album.find_by(title: "Use Your Illusion II").artist

🀨 Medium level

  • How many albums have "Great" in their title?

    Album.where("title like ?", "%great%").count
  • eletes all the albums whose name contains "music".

    Album.where("title like ?", "%music%").destroy_all
  • How many albums are there written by AC/DC ?

    Album.where(artist: "AC/DC").count
  • How many songs last exactly 158589 milliseconds?

    Track.where(duration: 158589).count

πŸ˜΅β€πŸ’« Difficult level

  • puts in console all the titles of AC/DC.

    Track.where(artist: "AC/DC").each do |track|
      puts track.title
    end
  • puts in console all the titles of the album "Let There Be Rock".

    Track.where(album: "Let There Be Rock").each do |track|
      puts track.title
    end
  • Calculate the total price of this album and its total duration.

    price = Track.where(album: "Let There Be Rock").sum(:price).round(2)
    duration = Track.where(album: "Let There Be Rock").sum(:duration)
    puts "#{price}, #{duration}"
  • Calculate the cost of the entire "Deep Purple" discography.

    Track.where(artist: "Deep Purple").sum(:price).round(2)
  • Modify (via a loop) all the titles of "Eric Clapton" so that they are displayed with "Britney Spears" in artist.

    Track.where(artist: "Eric Clapton").each do |track|
      track.update(artist: 'Britney Spears')
    end

About

πŸš€πŸ’― The Hacking Project - Chinook Music 🎸 🎡


Languages

Language:Ruby 92.1%Language:HTML 4.5%Language:JavaScript 2.9%Language:CSS 0.6%