Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b82272d
Updated file structures
mnavoy4 Jul 7, 2020
850a751
Merge pull request #1 from mnavoy4/file-structures
mnavoy4 Jul 7, 2020
fb30191
Created class and migration files
mnavoy4 Jul 7, 2020
7cd3e5d
Merge pull request #2 from mnavoy4/file-structures
mnavoy4 Jul 7, 2020
6395fbf
added a new line on cli.rb
bgordon8 Jul 8, 2020
d5e1108
MVP complete
mnavoy4 Jul 8, 2020
8f0dee4
Merge pull request #3 from mnavoy4/bmg/testBranch
mnavoy4 Jul 8, 2020
a7605be
Revert "added a new line on cli.rb"
mnavoy4 Jul 8, 2020
1586376
Merge pull request #5 from mnavoy4/revert-3-bmg/testBranch
mnavoy4 Jul 8, 2020
cb5af5b
Merge pull request #4 from mnavoy4/Working-towards-mvp
mnavoy4 Jul 8, 2020
b99f900
Basic Main Menu Complete
mnavoy4 Jul 8, 2020
b4f9109
Connecting tables
mnavoy4 Jul 8, 2020
bb10aa4
Merge pull request #6 from mnavoy4/Adding-workouts-to-users_workouts
mnavoy4 Jul 8, 2020
306f72f
Added funtionality in seeing user profile
mnavoy4 Jul 8, 2020
0c3eee9
Merge pull request #7 from mnavoy4/Adding-workouts-to-users_workouts
mnavoy4 Jul 8, 2020
6b6876f
Changed user to member in all places
mnavoy4 Jul 9, 2020
fa689cd
Merge pull request #8 from mnavoy4/readability-updates
mnavoy4 Jul 9, 2020
d30b924
Now changed user to member in all places
mnavoy4 Jul 9, 2020
56a8415
Merge pull request #9 from mnavoy4/readability-updates
mnavoy4 Jul 9, 2020
9e57efb
Refactored methods, added delete profile feature, added edit profile …
mnavoy4 Jul 9, 2020
99e3304
Merge pull request #10 from mnavoy4/Refactor-edit_profile-delete_profile
mnavoy4 Jul 9, 2020
7d7ae34
Refactoring and improvements after Ahmeds feedback
mnavoy4 Jul 9, 2020
1ab65a0
Merge pull request #11 from mnavoy4/Heavy_refactoring-Split_up_menus-…
mnavoy4 Jul 10, 2020
6eede71
Small touch ups
mnavoy4 Jul 10, 2020
9e64038
Merge pull request #12 from mnavoy4/Heavy_refactoring-Split_up_menus-…
mnavoy4 Jul 10, 2020
2781e96
this updates the readme and adds a license doc
derekturner272 Jul 10, 2020
59edb9f
update license link
derekturner272 Jul 10, 2020
f2f6c4d
fixes to license link
derekturner272 Jul 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ gem "sinatra-activerecord", "~> 2.0"
gem "rake", "~> 13.0"
gem "sqlite3", "~> 1.4"
gem "require_all", "~> 3.0"
gem 'tty-prompt'
gem 'tty-progressbar'
gem 'tty-table'
40 changes: 39 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ GEM
zeitwerk (~> 2.2)
coderay (1.1.2)
concurrent-ruby (1.1.5)
equatable (0.6.1)
i18n (1.7.0)
concurrent-ruby (~> 1.0)
method_source (0.9.2)
minitest (5.13.0)
mustermann (1.0.3)
necromancer (0.5.1)
pastel (0.7.4)
equatable (~> 0.6)
tty-color (~> 0.5)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
Expand All @@ -36,10 +41,40 @@ GEM
activerecord (>= 3.2)
sinatra (>= 1.0)
sqlite3 (1.4.1)
strings (0.1.8)
strings-ansi (~> 0.1)
unicode-display_width (~> 1.5)
unicode_utils (~> 1.4)
strings-ansi (0.1.0)
thread_safe (0.3.6)
tilt (2.0.10)
tty-color (0.5.1)
tty-cursor (0.7.1)
tty-progressbar (0.17.0)
strings-ansi (~> 0.1.0)
tty-cursor (~> 0.7)
tty-screen (~> 0.7)
unicode-display_width (~> 1.6)
tty-prompt (0.21.0)
necromancer (~> 0.5.0)
pastel (~> 0.7.0)
tty-reader (~> 0.7.0)
tty-reader (0.7.0)
tty-cursor (~> 0.7)
tty-screen (~> 0.7)
wisper (~> 2.0.0)
tty-screen (0.8.0)
tty-table (0.11.0)
equatable (~> 0.6)
necromancer (~> 0.5)
pastel (~> 0.7.2)
strings (~> 0.1.5)
tty-screen (~> 0.7)
tzinfo (1.2.5)
thread_safe (~> 0.1)
unicode-display_width (1.7.0)
unicode_utils (1.4.0)
wisper (2.0.1)
zeitwerk (2.2.2)

PLATFORMS
Expand All @@ -52,6 +87,9 @@ DEPENDENCIES
require_all (~> 3.0)
sinatra-activerecord (~> 2.0)
sqlite3 (~> 1.4)
tty-progressbar
tty-prompt
tty-table

BUNDLED WITH
2.0.2
2.1.4
674 changes: 674 additions & 0 deletions License.txt

Large diffs are not rendered by default.

147 changes: 92 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,108 @@
# Mod 1 ActiveRecord Starter Repo
# GitFit Workout Tracker
___
A great new workout tracking app.

In `config/database.yml`, you can change the name of the database from `db/cats.sqlite3` to whatever reflects your project. For example: `db/notes.sqlite3`. Doesn't really matter what you call the db.
### Guide
___
1. Basic Info
2. Demo
3. Supporting Technologies
4. Install and Setup
5. Features
6. Status
7. Contact
8. License

### 1. Basic Info
___
GitFit is a workout tracking app that helps you track your gym sessions and make progress toward your fitness goals. The app is simple and intuitive to help its users stay focused on getting fit. Each user has a unique profile where their gym sessions are logged and their fitness goals can be updated as they are achieved.

### 2. Demo
___
Here's a video demo of [GitFit](https://www.youtube.com/watch?v=4XssJz04vVM&feature=youtu.be) on YouTube.

## ActiveRecord Methods
These common ActiveRecord methods will help you interact with your database. Please refer to the ActiveRecord
docs for what they do and how to use them. (If the docs talk about Rails, that is ok! ActiveRecord works very
similar with or without Rails.)
```
.create (.new, .save)
.all
.count
.find
.find_by
.where
```
### 3. Supporting Technologies
___

#### Notes
- Ruby -> 2.6.1
- ActiveRecord -> 6.0
- Sinatra-ActiveRecord -> 2.0
- Rake -> 13.0
- SQLite3 -> 1.4
- tty-prompt
- tty-font
- tty-progressbar
- tty-table

*Remember*, any model that will have a corresponding table in the database needs to inherit from `ActiveRecord::Base`
ex:
### 4. Install and Setup
___
To run GitFit clone it from the GitHub repository and install locally.

Run commands:
```
class Cat < ActiveRecord::Base
# customer methods defined here
end
rake db:migrate
bundle install
```

- To view database, you can run `sqlite3 db/cats.db`, then can run `.schema` or `.tables` and can run any SQL commands. (Don't need to do this anymore though! ActiveRecord gives us a schema file!)
### 5. Features
___

- Create new Member Profile
- See Member Profile
- Edit Member Profile
- Select Workout
- Delete Member Profile

___
```
def self.create_new
name = self.ask_for_name
goal = self.ask_for_goal
Member.create(:name=>name, :goal=>goal)
end
```
```
def workout
bar = TTY::ProgressBar.new($pastel.green("Work out in progress [:bar]"), total: 30)
30.times do
sleep(0.1)
bar.advance(1)
end
puts $pastel.green("Great job! You finished your workout.")
end

```
```
def display_member_workouts_table
hash = {}
workout_array = self.workouts.map(&:body_part)
workout_array.each { |value| hash[value] ? hash[value] += 1 : hash[value] = 1 }
table = TTY::Table.new ['Body Part','Workouts Completed'], hash.to_a
$pastel.cyan.bold(table.render(:ascii))
end
```

### Steps to setup Ruby app with activerecord
(New for ActiveRecord 6.0)
___

### 6. Status
___

## The following steps are already done for you in this boiler plate repo.
## The steps below are provided to you as a reference only.
## You're not expected to memorize this (please don't).
Current status: Functional MVP completed
To-do's:

- [x] fix member sign in
- [x] add styling
- [x] complete documentation
- [x] make demo video
- [ ] include descriptions of exercises (maybe with pictures or videos)


1. In root of project, run `bundle init`
1. Add gems:
`bundle add activerecord pry sinatra, sinatra-activerecord rake sqlite3 require_all`
run `bundle install`
1. mkdir config and lib
1. mkdir lib/models
1. touch config/environment.rb config/database.yml
1. Create your model files and models (make sure to have your models inherit from ActiveRecord::Base)
1. In config/environment.rb:
```
require 'bundler/setup'
Bundler.require

require_all 'lib'
```
1. In config/database.yml:
```
development:
adapter: sqlite3
database: db/cats.sqlite3
```
1. Touch Rakefile - require ‘config/environment.rb’ and require_relative ‘sinatra/activerecord/rake’
1. Run rake -T to make sure we have access to raketasks
1. Run `rake db:create_migration NAME=create_cats_table` (will create the db folder if it doesn’t already exist) and will add the migration file to db/migration
1. Write migration file, then run `rake db:migrate`
1. Then can see schema in file structure, can also drop into sqlite3 cats.db to see the tables and schema, but don’t really need to do that anymore. *Review rollback here*
1. Create seeds in db/seeds.rb and run `rake db:seed`
1. Now can put a pry in environment.rb to run <ModelName>.all and see your seeds.

Make sure your models inherit from `ActiveRecord::Base`
### 7. Contact
___
GitFit was created by [Michael Navoy](https://www.linkedin.com/in/michael-navoy/), [Brian Gordon](https://github.com/bgordon8), and [Derek Turner](https://www.linkedin.com/in/derek-turner-1354b71b1/).

### 8. Lisence
___
[Click here to view](https://github.com/mnavoy4/GitFit_CLI_app/blob/master/License.txt)
7 changes: 6 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
require_relative 'config/environment'
require 'sinatra/activerecord/rake'
require 'sinatra/activerecord/rake'

desc "start console"
task :console do
Pry.start
end
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
development:
adapter: sqlite3
database: db/cats.sqlite3
database: db/GitFit_db.sqlite3
5 changes: 4 additions & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require 'bundler/setup'
Bundler.require

require_all 'lib'
require 'active_record'
require_all 'lib'
require_relative '../db/seeds'
ActiveRecord::Base.logger = nil
9 changes: 9 additions & 0 deletions db/migrate/001_create_members.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateMembers < ActiveRecord::Migration[6.0]

def change
create_table :members do |t|
t.string :name
t.string :goal
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/002_create_gym_sessions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateGymSessions < ActiveRecord::Migration[6.0]

def change
create_table :gym_sessions do |t|
t.references :member
t.references :workout
end
end
end
8 changes: 8 additions & 0 deletions db/migrate/003_create_workouts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CreateWorkouts < ActiveRecord::Migration[6.0]

def change
create_table :workouts do |t|
t.string :body_part
end
end
end
31 changes: 31 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -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: 3) do

create_table "gym_sessions", force: :cascade do |t|
t.integer "member_id"
t.integer "workout_id"
t.index ["member_id"], name: "index_gym_sessions_on_member_id"
t.index ["workout_id"], name: "index_gym_sessions_on_workout_id"
end

create_table "members", force: :cascade do |t|
t.string "name"
t.string "goal"
end

create_table "workouts", force: :cascade do |t|
t.string "body_part"
end

end
27 changes: 27 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Workout.destroy_all
# Member.destroy_all
# GymSession.destroy_all

# michael = Member.create(:name=>"Michael", :goal=>"strength")
# derek = Member.create(:name=>"Derek", :goal=>"Weight Loss")
# gordo = Member.create(:name=>"Gordo", :goal=>"strength")

# chest_workout = Workout.create(:body_part=>"Chest")
# back_workout = Workout.create(:body_part=>"back")
# arms_workout = Workout.create(:body_part=>"arms")

# session1 = GymSession.create()
# session2 = GymSession.create()
# session3 = GymSession.create()

# session1.member = michael
# session2.member = derek
# session3.member = gordo

# michael.gym_sessions << session1
# gordo.gym_sessions << session3
# derek.gym_sessions << session2

# chest_workout.gym_sessions << session1
# back_workout.gym_sessions << session2
# arms_workout.gym_sessions << session3
Loading