-
Notifications
You must be signed in to change notification settings - Fork 1
Phase 1 enahancement 72 #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
bbefc45
7880073
4f4e5a1
2e26380
4d6cd66
a1af633
a6b1487
0b1031b
939c5dc
dc2a956
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,9 @@ class Link < ActiveRecord::Base | |
| belongs_to :learning_status | ||
| belongs_to :link_type | ||
|
|
||
| def self.learn_time(user) | ||
| LearnTime.create!(user_id: user.id, link_id: self.id) | ||
| end | ||
| scope :order_by_created_at, -> { order(:created_at => :desc) } | ||
|
|
||
| scope :order_by_updated_at, -> { order(:updated_at => :desc) } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User ruby 2 style hash notation |
||
|
|
||
| def create_favourite(user_id, link_id) | ||
| favourites.create!(user_id: user_id, link_id: link_id) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,15 +11,19 @@ class User < ActiveRecord::Base | |
| has_many :links | ||
| has_many :learn_time | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't |
||
|
|
||
| def self.get_all_link(user, date) | ||
| user.links.where("created_at >= ?", date).group('date(created_at)').count | ||
| def links_till( date) | ||
| links.where("created_at >= ?", date).group('date(created_at)').count | ||
| end | ||
|
|
||
| def favourite_links | ||
| self.links.where(favourite: true) | ||
| end | ||
|
|
||
| def current_user_links | ||
| self.links | ||
| def user_learned_links | ||
| learn_time.order(:created_at => :desc).map { |link| link.link }.uniq | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User ruby 2 style hash notation |
||
| end | ||
|
|
||
| def user_learn_count_till(date) | ||
| learn_time.where("created_at >= ?", date).group('date(created_at)').count | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,13 @@ | |
| <% if @links.blank? %> | ||
| <div class="no_links_msg">You do not have anything to display at this time. <%= link_to 'Start saving one now!', new_link_path%></div> | ||
| <% else %> | ||
| <div class="col-lg-8 col-md-8 col-sm-8 links" id="links-list"> | ||
| <%= render partial: 'links/links_list', locals: { links: @links}%> | ||
| <div class="col-lg-8 col-md-8 col-sm-8" id="links-list"> | ||
| <%= form_tag sort_links_path, remote: true, id: 'sorting_form' do %> | ||
| <%= select_tag :sort_by, options_for_select(['Added On', 'Updated On', 'Recently Learned', 'Learn Count' ]), class: "select_box" %> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move sort option to a constant in |
||
| <% end %> | ||
| <div class="links"> | ||
| <%= render partial: 'links/links_list', locals: { links: @links}%> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. required space before |
||
| </div> | ||
| </div> | ||
| <div class="col-lg-3 col-md-3 col-sm-3 showback tag-cloud-width"> | ||
| <% tag_cloud Link.tag_counts, %w{s m l} do |tag, css_class| %> | ||
|
|
@@ -16,4 +21,9 @@ | |
| </div> | ||
| <% end %> | ||
| </div> | ||
| </section> | ||
| </section> | ||
| <script type="text/javascript"> | ||
| $('.select_box').change(function(){ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Binding |
||
| $('#sorting_form').submit(); | ||
| }); | ||
| </script> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| $('.links').html("<%= escape_javascript(render partial: 'links/links_list', locals: { links: @links})%>"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| Rails.application.routes.draw do | ||
|
|
||
| root 'links#index' | ||
| get 'links/favourites' => 'links#favourites', :as => :favourite_links | ||
| get 'links/import_form' => 'links#import_form', :as => :links_import_form | ||
| get 'links/favourites' => 'links#favourites', as: :favourite_links | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move all |
||
| get 'links/import_form' => 'links#import_form', as: :links_import_form | ||
| post 'links/sort_links' => 'links#sort_links', as: :sort_links | ||
|
|
||
| resources :links do | ||
| collection { post :import } | ||
| end | ||
|
|
@@ -17,7 +19,7 @@ | |
| # devise_scope :users do | ||
| # get '/users' => 'users#index' | ||
| # end | ||
| post 'links/toggle' => 'favourites#toggle', :as => :toggle_favourite | ||
| post 'links/toggle' => 'favourites#toggle', as: :toggle_favourite | ||
| devise_for :users, controllers: { sessions: 'users/sessions', registrations: 'users/registrations', passwords: 'users/passwords'} | ||
|
|
||
| # You can have the root of your site routed with "root" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User ruby 2 style hash notation