Commit 38a7bb2
Changed files (8)
app
assets
stylesheets
models
views
layouts
profiles
app/assets/stylesheets/profiles.scss
@@ -0,0 +1,6 @@
+.profiles {
+ table {
+ margin-left: auto;
+ margin-right: auto;
+ }
+}
app/models/user.rb
@@ -24,6 +24,17 @@ class User < ActiveRecord::Base
max
end
+ def history_for(exercise)
+ exercise_sessions.
+ includes(:training_session).
+ joins(:exercise).
+ where(exercises: { name: exercise.name }).
+ inject({}) do |memo, session|
+ memo[session.training_session.occurred_at] = session.target_weight
+ memo
+ end
+ end
+
def self.authenticate(username,password)
if user = User.where("email = :email OR username = :username", username: username, email: username).first
user.authenticate(password)
app/views/layouts/application.html.erb
@@ -6,6 +6,10 @@
<title><%= content_for?(:title) ? "Strong Lifters | #{yield(:title)}" : "Strong Lifters" %></title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "vendor/modernizr" %>
+ <%= javascript_include_tag "application" %>
+ <script type="text/javascript" charset="utf-8">
+ $(function(){ $(document).foundation(); });
+ </script>
<%= csrf_meta_tags %>
</head>
<body>
@@ -84,7 +88,7 @@
</div>
<div class="large-6 columns">
<ul class="inline-list right">
- <li><a href="#">Link 1</a></li>
+ <li><a href="https://twitter.com/StrongLifters/">Twitter</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
@@ -96,9 +100,5 @@
<!-- End Footer -->
</div>
</div>
- <%= javascript_include_tag "application" %>
- <script type="text/javascript" charset="utf-8">
- $(function(){ $(document).foundation(); });
- </script>
</body>
</html>
app/views/layouts/public.html.erb
@@ -6,9 +6,14 @@
<title><%= content_for?(:title) ? yield(:title) : "Strong Lifters" %></title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "vendor/modernizr" %>
+ <%= javascript_include_tag "application" %>
+ <%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %>
+ <script type="text/javascript" charset="utf-8">
+ $(function(){ $(document).foundation(); });
+ </script>
<%= csrf_meta_tags %>
</head>
- <body>
+ <body class="<%= controller_name %>">
<%= render partial: 'layouts/flash' %>
<header>
<div class="row">
@@ -18,9 +23,5 @@
</div>
</header>
<%= yield %>
- <%= javascript_include_tag "application" %>
- <script type="text/javascript" charset="utf-8">
- $(function(){ $(document).foundation(); });
- </script>
</body>
</html>
app/views/profiles/show.html.erb
@@ -1,9 +1,9 @@
<div class="small-12 columns">
<div class="row">
- <div class="small-3 columns">
+ <div class="small-2 columns">
</div>
- <div class="small-6 columns text-center">
+ <div class="small-8 columns text-center">
<%= link_to profile_path(@user), class: 'th [radius]' do %>
<%= gravatar_for(@user, size: 128) %>
<% end %>
@@ -26,8 +26,14 @@
<% end %>
</tbody>
</table>
+
+ <h2>Training History</h2>
+ <% @program.exercises.uniq.each do |exercise| %>
+ <p><%= exercise.name %></p>
+ <%= line_chart @user.history_for(exercise) %>
+ <% end %>
</div>
- <div class="small-3 columns">
+ <div class="small-2 columns">
</div>
</div>
.gitignore
@@ -19,3 +19,4 @@ coverage
config/deploy_id_rsa
pkg
public/assets
+erd.pdf
Gemfile
@@ -35,6 +35,8 @@ gem 'puma'
gem 'rack-timeout'
gem 'scale'
gem 'dotenv-rails'
+gem 'chartkick'
+gem 'groupdate'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Gemfile.lock
@@ -67,6 +67,7 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
+ chartkick (1.3.2)
choice (0.2.0)
cliver (0.3.2)
coercible (1.0.0)
@@ -119,6 +120,8 @@ GEM
sass (>= 3.3.0, < 3.5)
globalid (0.3.5)
activesupport (>= 4.1.0)
+ groupdate (2.4.0)
+ activesupport (>= 3)
highline (1.7.1)
http-cookie (1.0.2)
domain_name (~> 0.5)
@@ -314,6 +317,7 @@ DEPENDENCIES
capistrano-bundler (~> 1.1)
capistrano-rails
capistrano-rbenv (~> 2.0)
+ chartkick
coffee-rails (~> 4.1.0)
coveralls
database_cleaner
@@ -323,6 +327,7 @@ DEPENDENCIES
ffaker
foreman
foundation-rails
+ groupdate
i18n-tasks
jbuilder (~> 2.0)
jquery-rails