mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Code style fixes
This commit is contained in:
parent
c6bbc67dab
commit
d8acf60049
72 changed files with 458 additions and 594 deletions
|
|
@ -1,6 +1,18 @@
|
||||||
engines:
|
engines:
|
||||||
|
brakeman:
|
||||||
|
enabled: true
|
||||||
|
fixme:
|
||||||
|
enabled: true
|
||||||
|
flog:
|
||||||
|
enabled: true
|
||||||
|
reek:
|
||||||
|
enabled: true
|
||||||
rubocop:
|
rubocop:
|
||||||
enabled: true
|
enabled: true
|
||||||
checks:
|
checks:
|
||||||
Rubocop/Style/StringLiterals:
|
Rubocop/Style/StringLiterals:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
Rubocop/Style/TrailingCommaInLiteral:
|
||||||
|
enabled: false
|
||||||
|
Rubocop/Style/HashSyntax:
|
||||||
|
enabled: false
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@ class ApplicationController < ActionController::Base
|
||||||
# Returns a count of next actions in the given context or project The result
|
# Returns a count of next actions in the given context or project The result
|
||||||
# is count and a string descriptor, correctly pluralised if there are no
|
# is count and a string descriptor, correctly pluralised if there are no
|
||||||
# actions or multiple actions
|
# actions or multiple actions
|
||||||
#
|
|
||||||
def count_undone_todos_phrase(todos_parent)
|
def count_undone_todos_phrase(todos_parent)
|
||||||
count = count_undone_todos(todos_parent)
|
count = count_undone_todos(todos_parent)
|
||||||
deferred_count = count_deferred_todos(todos_parent)
|
deferred_count = count_deferred_todos(todos_parent)
|
||||||
|
|
@ -83,13 +82,13 @@ class ApplicationController < ActionController::Base
|
||||||
init_hidden_todo_counts(['context']) if !@context_hidden_todo_counts
|
init_hidden_todo_counts(['context']) if !@context_hidden_todo_counts
|
||||||
count = @context_hidden_todo_counts[todos_parent.id]
|
count = @context_hidden_todo_counts[todos_parent.id]
|
||||||
else
|
else
|
||||||
count = eval "@#{todos_parent.class.to_s.downcase}_not_done_counts[#{todos_parent.id}]"
|
count = eval("@#{todos_parent.class.to_s.downcase}_not_done_counts[#{todos_parent.id}]", binding, __FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
count || 0
|
count || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_deferred_todos(todos_parent)
|
def count_deferred_todos(todos_parent)
|
||||||
return todos_parent.nil? ? 0 : eval("@#{todos_parent.class.to_s.downcase}_deferred_counts[#{todos_parent.id}]") || 0
|
return todos_parent.nil? ? 0 : eval("@#{todos_parent.class.to_s.downcase}_deferred_counts[#{todos_parent.id}]", binding, __FILE__, __LINE__) || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# Convert a date object to the format specified in the user's preferences in
|
# Convert a date object to the format specified in the user's preferences in
|
||||||
|
|
@ -222,14 +221,14 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def init_not_done_counts(parents=['project', 'context'])
|
def init_not_done_counts(parents=['project', 'context'])
|
||||||
parents.each do |parent|
|
parents.each do |parent|
|
||||||
eval("@#{parent}_not_done_counts ||= current_user.todos.active.count_by_group('#{parent}_id')")
|
eval("@#{parent}_not_done_counts ||= current_user.todos.active.count_by_group('#{parent}_id')", binding, __FILE__, __LINE__)
|
||||||
eval("@#{parent}_deferred_counts ||= current_user.todos.deferred.count_by_group('#{parent}_id')")
|
eval("@#{parent}_deferred_counts ||= current_user.todos.deferred.count_by_group('#{parent}_id')", binding, __FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_hidden_todo_counts(parents=['project', 'context'])
|
def init_hidden_todo_counts(parents=['project', 'context'])
|
||||||
parents.each do |parent|
|
parents.each do |parent|
|
||||||
eval("@#{parent}_hidden_todo_counts ||= current_user.todos.active_or_hidden.count_by_group('#{parent}_id')")
|
eval("@#{parent}_hidden_todo_counts ||= current_user.todos.active_or_hidden.count_by_group('#{parent}_id')", binding, __FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -263,8 +262,8 @@ class ApplicationController < ActionController::Base
|
||||||
@source_view = "all_done"
|
@source_view = "all_done"
|
||||||
@page_title = t("#{object_name.pluralize}.all_completed_tasks_title", "#{object_name}_name".to_sym => object.name)
|
@page_title = t("#{object_name.pluralize}.all_completed_tasks_title", "#{object_name}_name".to_sym => object.name)
|
||||||
|
|
||||||
@done = object.todos.completed.reorder('completed_at DESC').includes(Todo::DEFAULT_INCLUDES).
|
@done = object.todos.completed.reorder('completed_at DESC').includes(Todo::DEFAULT_INCLUDES)
|
||||||
paginate(:page => params[:page], :per_page => 20)
|
.paginate(:page => params[:page], :per_page => 20)
|
||||||
@count = @done.size
|
@count = @done.size
|
||||||
render :template => 'todos/all_done'
|
render :template => 'todos/all_done'
|
||||||
end
|
end
|
||||||
|
|
@ -284,5 +283,4 @@ class ApplicationController < ActionController::Base
|
||||||
def set_group_view_by
|
def set_group_view_by
|
||||||
@group_view_by = params['_group_view_by'] || cookies['group_view_by'] || 'context'
|
@group_view_by = params['_group_view_by'] || cookies['group_view_by'] || 'context'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class ContextsController < ApplicationController
|
class ContextsController < ApplicationController
|
||||||
|
|
||||||
helper :todos
|
helper :todos
|
||||||
|
|
||||||
before_action :init, :except => [:index, :create, :destroy, :order]
|
before_action :init, :except => [:index, :create, :destroy, :order]
|
||||||
|
|
@ -93,7 +92,6 @@ class ContextsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# Edit the details of the context
|
# Edit the details of the context
|
||||||
#
|
|
||||||
def update
|
def update
|
||||||
process_params_for_update
|
process_params_for_update
|
||||||
|
|
||||||
|
|
@ -270,5 +268,4 @@ class ContextsController < ApplicationController
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class DataController < ApplicationController
|
class DataController < ApplicationController
|
||||||
|
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
@ -7,7 +6,6 @@ class DataController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def import
|
def import
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def csv_map
|
def csv_map
|
||||||
|
|
@ -147,8 +145,7 @@ class DataController < ApplicationController
|
||||||
def csv_notes
|
def csv_notes
|
||||||
content_type = 'text/csv'
|
content_type = 'text/csv'
|
||||||
CSV.generate(result = "") do |csv|
|
CSV.generate(result = "") do |csv|
|
||||||
csv << ["id", "User ID", "Project", "Note",
|
csv << ["id", "User ID", "Project", "Note", "Created at", "Updated at"]
|
||||||
"Created at", "Updated at"]
|
|
||||||
# had to remove project include because it's association order is leaking
|
# had to remove project include because it's association order is leaking
|
||||||
# through and causing an ambiguous column ref even with_exclusive_scope
|
# through and causing an ambiguous column ref even with_exclusive_scope
|
||||||
# didn't seem to help -JamesKebinger
|
# didn't seem to help -JamesKebinger
|
||||||
|
|
@ -210,8 +207,8 @@ class DataController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def sanitize_filename(filename)
|
def sanitize_filename(filename)
|
||||||
filename.gsub(/[^0-9A-z.\-]/, '_')
|
filename.gsub(/[^0-9A-z.\-]/, '_')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class FeedlistController < ApplicationController
|
class FeedlistController < ApplicationController
|
||||||
|
|
||||||
helper :feedlist
|
helper :feedlist
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
@ -41,5 +40,4 @@ class FeedlistController < ApplicationController
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,4 @@ class IntegrationsController < ApplicationController
|
||||||
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,5 +82,4 @@ class LoginController < ApplicationController
|
||||||
return Time.now + 10 unless session['expiry_time']
|
return Time.now + 10 unless session['expiry_time']
|
||||||
DateTime.strptime(session['expiry_time'], "%FT%T.%L%Z")
|
DateTime.strptime(session['expiry_time'], "%FT%T.%L%Z")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
require 'openssl'
|
require 'openssl'
|
||||||
|
|
||||||
class MailgunController < ApplicationController
|
class MailgunController < ApplicationController
|
||||||
|
|
||||||
skip_before_action :login_required, :only => [:mailgun]
|
skip_before_action :login_required, :only => [:mailgun]
|
||||||
before_action :verify, :only => [:mailgun]
|
before_action :verify, :only => [:mailgun]
|
||||||
protect_from_forgery with: :null_session
|
protect_from_forgery with: :null_session
|
||||||
|
|
@ -34,5 +33,4 @@ class MailgunController < ApplicationController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class NotesController < ApplicationController
|
class NotesController < ApplicationController
|
||||||
|
|
||||||
before_action :set_source_view
|
before_action :set_source_view
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
@ -75,5 +74,4 @@ class NotesController < ApplicationController
|
||||||
def note_params
|
def note_params
|
||||||
params.require(:note).permit(:project_id, :body)
|
params.require(:note).permit(:project_id, :body)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class PreferencesController < ApplicationController
|
class PreferencesController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@page_title = t('preferences.page_title')
|
@page_title = t('preferences.page_title')
|
||||||
@prefs = current_user.prefs
|
@prefs = current_user.prefs
|
||||||
|
|
@ -52,5 +51,4 @@ private
|
||||||
notify :notice, t('preferences.updated')
|
notify :notice, t('preferences.updated')
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class ProjectsController < ApplicationController
|
class ProjectsController < ApplicationController
|
||||||
|
|
||||||
helper :application, :todos, :notes
|
helper :application, :todos, :notes
|
||||||
before_action :set_source_view
|
before_action :set_source_view
|
||||||
before_action :set_project_from_params, :only => [:update, :destroy, :show, :edit, :set_reviewed]
|
before_action :set_project_from_params, :only => [:update, :destroy, :show, :edit, :set_reviewed]
|
||||||
|
|
@ -133,10 +132,10 @@ class ProjectsController < ApplicationController
|
||||||
@projects_to_show = [@project]
|
@projects_to_show = [@project]
|
||||||
|
|
||||||
@done = {}
|
@done = {}
|
||||||
@done = @project.todos.completed.
|
@done = @project.todos.completed
|
||||||
reorder("todos.completed_at DESC").
|
.reorder("todos.completed_at DESC")
|
||||||
limit(current_user.prefs.show_number_completed).
|
.limit(current_user.prefs.show_number_completed)
|
||||||
includes(Todo::DEFAULT_INCLUDES) unless @max_completed == 0
|
.includes(Todo::DEFAULT_INCLUDES) unless @max_completed == 0
|
||||||
|
|
||||||
@down_count = @not_done_todos.size + @deferred_todos.size + @pending_todos.size
|
@down_count = @not_done_todos.size + @deferred_todos.size + @pending_todos.size
|
||||||
@count = @down_count
|
@count = @down_count
|
||||||
|
|
@ -197,7 +196,6 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# Edit the details of the project
|
# Edit the details of the project
|
||||||
#
|
|
||||||
def update
|
def update
|
||||||
template = ""
|
template = ""
|
||||||
|
|
||||||
|
|
@ -350,5 +348,4 @@ class ProjectsController < ApplicationController
|
||||||
def project_params
|
def project_params
|
||||||
params.require(:project).permit(:name, :position, :user_id, :description, :state, :default_context_id, :default_tags)
|
params.require(:project).permit(:name, :position, :user_id, :description, :state, :default_context_id, :default_tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class FormHelper
|
class FormHelper
|
||||||
|
|
||||||
def initialize(recurring_todo)
|
def initialize(recurring_todo)
|
||||||
@recurring_todo = recurring_todo
|
@recurring_todo = recurring_todo
|
||||||
|
|
||||||
|
|
@ -47,7 +45,5 @@ module RecurringTodos
|
||||||
# no match, let @recurring_todo handle it, or fail
|
# no match, let @recurring_todo handle it, or fail
|
||||||
@recurring_todo.send(method, *args)
|
@recurring_todo.send(method, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class RecurringTodosController < ApplicationController
|
class RecurringTodosController < ApplicationController
|
||||||
|
|
||||||
helper :todos, :recurring_todos
|
helper :todos, :recurring_todos
|
||||||
|
|
||||||
append_before_action :init, :only => [:index, :new, :edit, :create]
|
append_before_action :init, :only => [:index, :new, :edit, :create]
|
||||||
|
|
@ -98,7 +97,6 @@ class RecurringTodosController < ApplicationController
|
||||||
@completed_remaining = current_user.recurring_todos.completed.count
|
@completed_remaining = current_user.recurring_todos.completed.count
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
||||||
format.html do
|
format.html do
|
||||||
if @saved
|
if @saved
|
||||||
notify :notice, t('todos.recurring_deleted_success')
|
notify :notice, t('todos.recurring_deleted_success')
|
||||||
|
|
@ -107,7 +105,6 @@ class RecurringTodosController < ApplicationController
|
||||||
end
|
end
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
format.js do
|
format.js do
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
@ -230,5 +227,4 @@ class RecurringTodosController < ApplicationController
|
||||||
where("fai_todos.id IS NULL").
|
where("fai_todos.id IS NULL").
|
||||||
each { |rt| current_user.recurring_todos.find(rt.id).toggle_completion! }
|
each { |rt| current_user.recurring_todos.find(rt.id).toggle_completion! }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class SearchController < ApplicationController
|
class SearchController < ApplicationController
|
||||||
|
|
||||||
helper :todos, :application, :notes, :projects, :contexts
|
helper :todos, :application, :notes, :projects, :contexts
|
||||||
|
|
||||||
def results
|
def results
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
class StatsController < ApplicationController
|
class StatsController < ApplicationController
|
||||||
|
SECONDS_PER_DAY = 86_400;
|
||||||
SECONDS_PER_DAY = 86400;
|
|
||||||
|
|
||||||
helper :todos, :projects, :recurring_todos
|
helper :todos, :projects, :recurring_todos
|
||||||
append_before_action :init, :except => :index
|
append_before_action :init, :except => :index
|
||||||
|
|
@ -52,7 +51,6 @@ class StatsController < ApplicationController
|
||||||
|
|
||||||
case params['id']
|
case params['id']
|
||||||
when 'avrt', 'avrt_end' # actions_visible_running_time
|
when 'avrt', 'avrt_end' # actions_visible_running_time
|
||||||
|
|
||||||
# HACK: because open flash chart uses & to denote the end of a parameter,
|
# HACK: because open flash chart uses & to denote the end of a parameter,
|
||||||
# we cannot use URLs with multiple parameters (that would use &). So we
|
# we cannot use URLs with multiple parameters (that would use &). So we
|
||||||
# revert to using two id's for the same selection. avtr_end means that the
|
# revert to using two id's for the same selection. avtr_end means that the
|
||||||
|
|
@ -72,9 +70,9 @@ class StatsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# get all running actions that are visible
|
# get all running actions that are visible
|
||||||
@actions_running_time = current_user.todos.not_completed.not_hidden.not_deferred_or_blocked.
|
@actions_running_time = current_user.todos.not_completed.not_hidden.not_deferred_or_blocked
|
||||||
select("todos.id, todos.created_at").
|
.select("todos.id, todos.created_at")
|
||||||
reorder("todos.created_at DESC")
|
.reorder("todos.created_at DESC")
|
||||||
|
|
||||||
selected_todo_ids = get_ids_from(@actions_running_time, week_from, week_to, params['id'] == 'avrt_end')
|
selected_todo_ids = get_ids_from(@actions_running_time, week_from, week_to, params['id'] == 'avrt_end')
|
||||||
@selected_actions = selected_todo_ids.size == 0 ? [] : current_user.todos.where("id in (" + selected_todo_ids.join(",") + ")")
|
@selected_actions = selected_todo_ids.size == 0 ? [] : current_user.todos.where("id in (" + selected_todo_ids.join(",") + ")")
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
module Todos
|
module Todos
|
||||||
class TodoCreateParamsHelper
|
class TodoCreateParamsHelper
|
||||||
|
|
||||||
attr_reader :new_project_created, :new_context_created, :attributes
|
attr_reader :new_project_created, :new_context_created, :attributes
|
||||||
|
|
||||||
def initialize(params, user)
|
def initialize(params, user)
|
||||||
|
|
@ -160,6 +159,5 @@ module Todos
|
||||||
rescue
|
rescue
|
||||||
@errors << { :attribute => group_type, :message => "unknown" }
|
@errors << { :attribute => group_type, :message => "unknown" }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class TodosController < ApplicationController
|
class TodosController < ApplicationController
|
||||||
|
|
||||||
skip_before_action :login_required, :only => [:index, :tag, :list_deferred, :show, :list_hidden, :done]
|
skip_before_action :login_required, :only => [:index, :tag, :list_deferred, :show, :list_hidden, :done]
|
||||||
prepend_before_action :login_or_feed_token_required, :only => [:index, :tag, :list_deferred, :show, :list_hidden, :done]
|
prepend_before_action :login_or_feed_token_required, :only => [:index, :tag, :list_deferred, :show, :list_hidden, :done]
|
||||||
append_before_action :find_and_activate_ready, :only => [:index, :list_deferred]
|
append_before_action :find_and_activate_ready, :only => [:index, :list_deferred]
|
||||||
|
|
@ -519,7 +518,6 @@ class TodosController < ApplicationController
|
||||||
@new_recurring_todo = check_for_next_todo(@todo) if @saved
|
@new_recurring_todo = check_for_next_todo(@todo) if @saved
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
||||||
format.html do
|
format.html do
|
||||||
if @saved
|
if @saved
|
||||||
message = t('todos.action_deleted_success')
|
message = t('todos.action_deleted_success')
|
||||||
|
|
@ -533,7 +531,6 @@ class TodosController < ApplicationController
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
format.js do
|
format.js do
|
||||||
if @saved
|
if @saved
|
||||||
determine_down_count
|
determine_down_count
|
||||||
|
|
@ -546,9 +543,7 @@ class TodosController < ApplicationController
|
||||||
end
|
end
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
format.xml { render :body => '200 OK. Action deleted.', :status => 200 }
|
format.xml { render :body => '200 OK. Action deleted.', :status => 200 }
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -650,10 +645,10 @@ class TodosController < ApplicationController
|
||||||
|
|
||||||
# If you've set no_completed to zero, the completed items box isn't shown on
|
# If you've set no_completed to zero, the completed items box isn't shown on
|
||||||
# the tag page
|
# the tag page
|
||||||
@done = todos_with_tag_ids.completed.
|
@done = todos_with_tag_ids.completed
|
||||||
limit(current_user.prefs.show_number_completed).
|
.limit(current_user.prefs.show_number_completed)
|
||||||
reorder('todos.completed_at DESC').
|
.reorder('todos.completed_at DESC')
|
||||||
includes(Todo::DEFAULT_INCLUDES)
|
.includes(Todo::DEFAULT_INCLUDES)
|
||||||
|
|
||||||
@projects = current_user.projects
|
@projects = current_user.projects
|
||||||
@contexts = current_user.contexts
|
@contexts = current_user.contexts
|
||||||
|
|
@ -705,7 +700,6 @@ class TodosController < ApplicationController
|
||||||
@tag = Tag.where(:name => @tag_name).first_or_create
|
@tag = Tag.where(:name => @tag_name).first_or_create
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
tags_beginning = current_user.tags.where(Tag.arel_table[:name].matches("#{params[:term]}%"))
|
tags_beginning = current_user.tags.where(Tag.arel_table[:name].matches("#{params[:term]}%"))
|
||||||
tags_all = current_user.tags.where(Tag.arel_table[:name].matches("%#{params[:term]}%"))
|
tags_all = current_user.tags.where(Tag.arel_table[:name].matches("%#{params[:term]}%"))
|
||||||
|
|
@ -765,14 +759,14 @@ class TodosController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_not_completed_for_predecessor(relation, todo_id=nil)
|
def get_not_completed_for_predecessor(relation, todo_id=nil)
|
||||||
items = relation.todos.not_completed.
|
items = relation.todos.not_completed
|
||||||
where('(LOWER(todos.description) ' + Common.like_operator + '?)', "%#{params[:term].downcase}%")
|
.where('(LOWER(todos.description) ' + Common.like_operator + '?)', "%#{params[:term].downcase}%")
|
||||||
items = items.where("AND NOT(todos.id=?)", todo_id) unless todo_id.nil?
|
items = items.where("AND NOT(todos.id=?)", todo_id) unless todo_id.nil?
|
||||||
|
|
||||||
items.
|
items
|
||||||
includes(:context, :project).
|
.includes(:context, :project)
|
||||||
reorder('description ASC').
|
.reorder('description ASC')
|
||||||
limit(10)
|
.limit(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def auto_complete_for_predecessor
|
def auto_complete_for_predecessor
|
||||||
|
|
@ -1096,7 +1090,6 @@ end
|
||||||
date_to_check ||= Time.zone.now
|
date_to_check ||= Time.zone.now
|
||||||
|
|
||||||
if recurring_todo.active? && recurring_todo.continues_recurring?(date_to_check)
|
if recurring_todo.active? && recurring_todo.continues_recurring?(date_to_check)
|
||||||
|
|
||||||
# shift the reference date to yesterday if date_to_check is furher in
|
# shift the reference date to yesterday if date_to_check is furher in
|
||||||
# the past. This is to make sure we do not get older todos for overdue
|
# the past. This is to make sure we do not get older todos for overdue
|
||||||
# todos. I.e. checking a daily todo that is overdue with 5 days will
|
# todos. I.e. checking a daily todo that is overdue with 5 days will
|
||||||
|
|
@ -1179,7 +1172,6 @@ end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def update_context
|
def update_context
|
||||||
@context_changed = false
|
@context_changed = false
|
||||||
if params['todo']['context_id'].blank? && params['context_name'].present?
|
if params['todo']['context_id'].blank? && params['context_name'].present?
|
||||||
|
|
@ -1322,5 +1314,4 @@ end
|
||||||
redirect_to(uri.path)
|
redirect_to(uri.path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
|
|
||||||
before_action :admin_login_required, :only => [:index, :show]
|
before_action :admin_login_required, :only => [:index, :show]
|
||||||
before_action :admin_or_self_login_required, :only => [:destroy]
|
before_action :admin_or_self_login_required, :only => [:destroy]
|
||||||
skip_before_action :login_required, :only => [:new, :create]
|
skip_before_action :login_required, :only => [:new, :create]
|
||||||
|
|
@ -223,5 +222,4 @@ class UsersController < ApplicationController
|
||||||
return false if params[:user][:password].empty?
|
return false if params[:user][:password].empty?
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -208,9 +208,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_delete(type, object, descriptor=sanitize(object.name))
|
def link_to_delete(type, object, descriptor=sanitize(object.name))
|
||||||
link_to(
|
link_to(descriptor, self.send("#{type}_path", object, :format => 'js'),
|
||||||
descriptor,
|
|
||||||
self.send("#{type}_path", object, :format => 'js'),
|
|
||||||
{
|
{
|
||||||
:id => "delete_#{type}_#{object.id}",
|
:id => "delete_#{type}_#{object.id}",
|
||||||
:class => "delete_#{type}_button icon",
|
:class => "delete_#{type}_button icon",
|
||||||
|
|
@ -250,5 +248,4 @@ module ApplicationHelper
|
||||||
def js_error_messages_for(object)
|
def js_error_messages_for(object)
|
||||||
escape_javascript(get_list_of_error_messages_for(object))
|
escape_javascript(get_list_of_error_messages_for(object))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module ContextsHelper
|
module ContextsHelper
|
||||||
|
|
||||||
def show_context_name(context)
|
def show_context_name(context)
|
||||||
if source_view_is :context
|
if source_view_is :context
|
||||||
content_tag(:span, :id => "context_name"){context.name}
|
content_tag(:span, :id => "context_name"){context.name}
|
||||||
|
|
@ -19,5 +18,4 @@ module ContextsHelper
|
||||||
def context_summary(context, undone_todo_count)
|
def context_summary(context, undone_todo_count)
|
||||||
content_tag(:p, "#{undone_todo_count}. Context is #{context.hidden? ? 'Hidden' : 'Active'}.".html_safe)
|
content_tag(:p, "#{undone_todo_count}. Context is #{context.hidden? ? 'Hidden' : 'Active'}.".html_safe)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module DateLabelHelper
|
module DateLabelHelper
|
||||||
|
|
||||||
class GenericDateView
|
class GenericDateView
|
||||||
include ActionView::Context
|
include ActionView::Context
|
||||||
include ActionView::Helpers
|
include ActionView::Helpers
|
||||||
|
|
@ -66,11 +65,9 @@ module DateLabelHelper
|
||||||
yield
|
yield
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class DueDateView < GenericDateView
|
class DueDateView < GenericDateView
|
||||||
|
|
||||||
def due_text
|
def due_text
|
||||||
case @days_sym
|
case @days_sym
|
||||||
when :overdue_by_one
|
when :overdue_by_one
|
||||||
|
|
@ -100,11 +97,9 @@ module DateLabelHelper
|
||||||
def due_date_mobile_html
|
def due_date_mobile_html
|
||||||
date_mobile_html_wrapper { @prefs.format_date(@due) }
|
date_mobile_html_wrapper { @prefs.format_date(@due) }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class ShowFromDateView < GenericDateView
|
class ShowFromDateView < GenericDateView
|
||||||
|
|
||||||
def show_from_text
|
def show_from_text
|
||||||
case @days_sym
|
case @days_sym
|
||||||
when :overdue_by_more_than_one, :overdue_by_one
|
when :overdue_by_more_than_one, :overdue_by_one
|
||||||
|
|
@ -127,7 +122,5 @@ module DateLabelHelper
|
||||||
def show_from_date_html
|
def show_from_date_html
|
||||||
date_html_wrapper { show_from_text }
|
date_html_wrapper { show_from_text }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module FeedlistHelper
|
module FeedlistHelper
|
||||||
|
|
||||||
def linkoptions(format, options)
|
def linkoptions(format, options)
|
||||||
merge_hashes( { :format => format }, options, user_token_hash)
|
merge_hashes( { :format => format }, options, user_token_hash)
|
||||||
end
|
end
|
||||||
|
|
@ -48,6 +47,4 @@ module FeedlistHelper
|
||||||
def user_token_hash
|
def user_token_hash
|
||||||
{ :token => current_user.token }
|
{ :token => current_user.token }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
module LoginHelper
|
module LoginHelper
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module PreferencesHelper
|
module PreferencesHelper
|
||||||
|
|
||||||
def pref(model, pref_name, &block)
|
def pref(model, pref_name, &block)
|
||||||
s = content_tag(:label, Preference.human_attribute_name(pref_name), :for => model + "_" + pref_name)
|
s = content_tag(:label, Preference.human_attribute_name(pref_name), :for => model + "_" + pref_name)
|
||||||
s << yield
|
s << yield
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module ProjectsHelper
|
module ProjectsHelper
|
||||||
|
|
||||||
def show_project_name(project)
|
def show_project_name(project)
|
||||||
if source_view_is :project
|
if source_view_is :project
|
||||||
content_tag(:span, :id => "project_name"){project.name}
|
content_tag(:span, :id => "project_name"){project.name}
|
||||||
|
|
@ -52,5 +51,4 @@ module ProjectsHelper
|
||||||
def link_to_edit_project (project, descriptor = sanitize(project.name))
|
def link_to_edit_project (project, descriptor = sanitize(project.name))
|
||||||
link_to_edit(:project, project, descriptor)
|
link_to_edit(:project, project, descriptor)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
module RecurringTodosHelper
|
module RecurringTodosHelper
|
||||||
|
|
||||||
def recurring_todo_tag_list
|
def recurring_todo_tag_list
|
||||||
tags_except_starred = @recurring_todo.tags.reject{ |t| t.name == Todo::STARRED_TAG_NAME }
|
tags_except_starred = @recurring_todo.tags.reject{ |t| t.name == Todo::STARRED_TAG_NAME }
|
||||||
tag_list = tags_except_starred.
|
tag_list = tags_except_starred
|
||||||
collect{|t| content_tag(:span,link_to(t.name, tag_path(t.name)), :class => "tag #{t.label}")}.
|
.collect{ |t| content_tag(:span,link_to(t.name, tag_path(t.name)), :class => "tag #{t.label}") }
|
||||||
join('')
|
.join('')
|
||||||
return content_tag :span, tag_list.html_safe, :class => "tags"
|
return content_tag :span, tag_list.html_safe, :class => "tags"
|
||||||
end
|
end
|
||||||
|
|
||||||
def recurring_todo_remote_delete_icon
|
def recurring_todo_remote_delete_icon
|
||||||
link_to( image_tag_for_delete,
|
link_to(image_tag_for_delete, recurring_todo_path(@recurring_todo),
|
||||||
recurring_todo_path(@recurring_todo), :id => "delete_icon_"+@recurring_todo.id.to_s,
|
:id => "delete_icon_" + @recurring_todo.id.to_s,
|
||||||
:class => "icon delete_icon", :title => t('todos.delete_recurring_action_title'), :x_confirm_message => t('todos.delete_recurring_action_confirm', :description => @recurring_todo.description))
|
:class => "icon delete_icon", :title => t('todos.delete_recurring_action_title'), :x_confirm_message => t('todos.delete_recurring_action_confirm', :description => @recurring_todo.description))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module StatsHelper
|
module StatsHelper
|
||||||
|
|
||||||
def font_size(cloud, tag)
|
def font_size(cloud, tag)
|
||||||
9 + 2 * cloud.relative_size(tag)
|
9 + 2 * cloud.relative_size(tag)
|
||||||
end
|
end
|
||||||
|
|
@ -19,5 +18,4 @@ module StatsHelper
|
||||||
def array_of_month_labels(count)
|
def array_of_month_labels(count)
|
||||||
Array.new(count) { |i| month_label(i) }
|
Array.new(count) { |i| month_label(i) }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
require 'staleness'
|
require 'staleness'
|
||||||
|
|
||||||
module TodosHelper
|
module TodosHelper
|
||||||
|
|
||||||
# === helpers for rendering container
|
# === helpers for rendering container
|
||||||
|
|
||||||
def empty_message_holder(container_name, show, title_param=nil)
|
def empty_message_holder(container_name, show, title_param=nil)
|
||||||
content_tag(:div, :id => "no_todos_in_view", :class => "container #{container_name}", :style => "display:" + (show ? "block" : "none") ) do
|
content_tag(:div, :id => "no_todos_in_view", :class => "container #{container_name}", :style => "display:" + (show ? "block" : "none") ) do
|
||||||
content_tag(:h2) { t("todos.no_actions.title", :param=>title_param) } +
|
content_tag(:h2) { t("todos.no_actions.title", :param=>title_param) } +
|
||||||
|
|
@ -143,8 +141,7 @@ module TodosHelper
|
||||||
:show_empty_containers => true,
|
:show_empty_containers => true,
|
||||||
:container_name => "#{period}",
|
:container_name => "#{period}",
|
||||||
:title =>t("todos.calendar.#{period}", :month => l(Time.zone.now, :format => "%B"), :next_month => l(1.month.from_now, :format => "%B"))
|
:title =>t("todos.calendar.#{period}", :month => l(Time.zone.now, :format => "%B"), :next_month => l(1.month.from_now, :format => "%B"))
|
||||||
}
|
} }
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# === helpers for rendering a todo
|
# === helpers for rendering a todo
|
||||||
|
|
@ -684,5 +681,4 @@ module TodosHelper
|
||||||
end
|
end
|
||||||
return container_id.blank? ? "" : "$(\"##{container_id}\").slideDown(100);".html_safe
|
return container_id.blank? ? "" : "$(\"##{container_id}\").slideDown(100);".html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class Context < ApplicationRecord
|
class Context < ApplicationRecord
|
||||||
|
|
||||||
has_many :todos, -> { order(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC")).includes(:project) }, :dependent => :delete_all
|
has_many :todos, -> { order(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC")).includes(:project) }, :dependent => :delete_all
|
||||||
has_many :recurring_todos, :dependent => :delete_all
|
has_many :recurring_todos, :dependent => :delete_all
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
@ -15,7 +14,6 @@ class Context < ApplicationRecord
|
||||||
include AASM
|
include AASM
|
||||||
|
|
||||||
aasm :column => :state do
|
aasm :column => :state do
|
||||||
|
|
||||||
state :active, :initial => true
|
state :active, :initial => true
|
||||||
state :closed
|
state :closed
|
||||||
state :hidden
|
state :hidden
|
||||||
|
|
@ -48,11 +46,9 @@ class Context < ApplicationRecord
|
||||||
def no_active_todos?
|
def no_active_todos?
|
||||||
return todos.active.count == 0
|
return todos.active.count == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class NullContext
|
class NullContext
|
||||||
|
|
||||||
def nil?
|
def nil?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
@ -64,5 +60,4 @@ class NullContext
|
||||||
def name
|
def name
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
class Dependency < ApplicationRecord
|
class Dependency < ApplicationRecord
|
||||||
|
|
||||||
# touch to make sure todo caches for predecessor and successor are invalidated
|
# touch to make sure todo caches for predecessor and successor are invalidated
|
||||||
|
|
||||||
belongs_to :predecessor, :foreign_key => 'predecessor_id', :class_name => 'Todo', :touch => true
|
belongs_to :predecessor, :foreign_key => 'predecessor_id', :class_name => 'Todo', :touch => true
|
||||||
belongs_to :successor, :foreign_key => 'successor_id', :class_name => 'Todo', :touch => true
|
belongs_to :successor, :foreign_key => 'successor_id', :class_name => 'Todo', :touch => true
|
||||||
|
|
||||||
validate :check_circular_dependencies
|
validate :check_circular_dependencies
|
||||||
|
|
||||||
def check_circular_dependencies
|
def check_circular_dependencies
|
||||||
unless predecessor.nil? or successor.nil?
|
unless predecessor.nil? || successor.nil?
|
||||||
errors.add("Depends on:", "Adding '#{successor.specification}' would create a circular dependency") if successor.is_successor?(predecessor)
|
errors.add("Depends on:", "Adding '#{successor.specification}' would create a circular dependency") if successor.is_successor?(predecessor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class MessageGateway < ActionMailer::Base
|
class MessageGateway < ActionMailer::Base
|
||||||
|
|
||||||
def receive(email)
|
def receive(email)
|
||||||
user = get_receiving_user_from_email_address(email)
|
user = get_receiving_user_from_email_address(email)
|
||||||
return false if user.nil?
|
return false if user.nil?
|
||||||
|
|
|
||||||
|
|
@ -32,5 +32,4 @@ class Preference < ApplicationRecord
|
||||||
def format_date(date)
|
def format_date(date)
|
||||||
return date ? date.in_time_zone(time_zone).strftime("#{date_format}") : ''
|
return date ? date.in_time_zone(time_zone).strftime("#{date_format}") : ''
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ class Project < ApplicationRecord
|
||||||
include AASM
|
include AASM
|
||||||
|
|
||||||
aasm :column => :state do
|
aasm :column => :state do
|
||||||
|
|
||||||
state :active, :initial => true
|
state :active, :initial => true
|
||||||
state :hidden
|
state :hidden
|
||||||
state :completed, :enter => :set_completed_at_date, :exit => :clear_completed_at_date
|
state :completed, :enter => :set_completed_at_date, :exit => :clear_completed_at_date
|
||||||
|
|
@ -145,11 +144,9 @@ class Project < ApplicationRecord
|
||||||
end
|
end
|
||||||
count
|
count
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class NullProject
|
class NullProject
|
||||||
|
|
||||||
def hidden?
|
def hidden?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
@ -169,5 +166,4 @@ class NullProject
|
||||||
def persisted?
|
def persisted?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class RecurringTodo < ApplicationRecord
|
||||||
validates_presence_of :description, :recurring_period, :target, :ends_on, :context
|
validates_presence_of :description, :recurring_period, :target, :ends_on, :context
|
||||||
|
|
||||||
validates_length_of :description, :maximum => 100
|
validates_length_of :description, :maximum => 100
|
||||||
validates_length_of :notes, :maximum => 60000, :allow_nil => true
|
validates_length_of :notes, :maximum => 60_000, :allow_nil => true
|
||||||
|
|
||||||
validate :period_validation
|
validate :period_validation
|
||||||
validate :pattern_specific_validations
|
validate :pattern_specific_validations
|
||||||
|
|
@ -72,7 +72,7 @@ class RecurringTodo < ApplicationRecord
|
||||||
|
|
||||||
def pattern
|
def pattern
|
||||||
if valid_period?
|
if valid_period?
|
||||||
@pattern = eval("RecurringTodos::#{recurring_period.capitalize}RecurrencePattern.new(user)")
|
@pattern = eval("RecurringTodos::#{recurring_period.capitalize}RecurrencePattern.new(user)", binding, __FILE__, __LINE__)
|
||||||
@pattern.build_from_recurring_todo(self)
|
@pattern.build_from_recurring_todo(self)
|
||||||
end
|
end
|
||||||
@pattern
|
@pattern
|
||||||
|
|
@ -138,5 +138,4 @@ class RecurringTodo < ApplicationRecord
|
||||||
def continues_recurring?(previous)
|
def continues_recurring?(previous)
|
||||||
pattern.continues_recurring?(previous)
|
pattern.continues_recurring?(previous)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class AbstractRecurrencePattern
|
class AbstractRecurrencePattern
|
||||||
|
|
||||||
attr_accessor :attributes
|
attr_accessor :attributes
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class AbstractRecurringTodosBuilder
|
class AbstractRecurringTodosBuilder
|
||||||
|
|
||||||
attr_reader :mapped_attributes, :pattern
|
attr_reader :mapped_attributes, :pattern
|
||||||
|
|
||||||
def initialize(user, attributes, pattern_class)
|
def initialize(user, attributes, pattern_class)
|
||||||
|
|
@ -10,8 +8,8 @@ module RecurringTodos
|
||||||
|
|
||||||
@attributes = attributes
|
@attributes = attributes
|
||||||
@selector = get_selector(selector_key)
|
@selector = get_selector(selector_key)
|
||||||
@filterred_attributes = filter_attributes(@attributes)
|
@filtered_attributes = filter_attributes(@attributes)
|
||||||
@mapped_attributes = map_attributes(@filterred_attributes)
|
@mapped_attributes = map_attributes(@filtered_attributes)
|
||||||
|
|
||||||
@pattern = pattern_class.new(user)
|
@pattern = pattern_class.new(user)
|
||||||
@pattern.attributes = @mapped_attributes
|
@pattern.attributes = @mapped_attributes
|
||||||
|
|
@ -60,11 +58,11 @@ module RecurringTodos
|
||||||
|
|
||||||
def filter_attributes(attributes)
|
def filter_attributes(attributes)
|
||||||
# get pattern independend attributes
|
# get pattern independend attributes
|
||||||
filterred_attributes = filter_generic_attributes(attributes)
|
filtered_attributes = filter_generic_attributes(attributes)
|
||||||
# append pattern specific attributes
|
# append pattern specific attributes
|
||||||
attributes_to_filter.each{|key| filterred_attributes[key]= attributes[key] if attributes.key?(key)}
|
attributes_to_filter.each{ |key| filtered_attributes[key]= attributes[key] if attributes.key?(key) }
|
||||||
|
|
||||||
filterred_attributes
|
filtered_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_generic_attributes(attributes)
|
def filter_generic_attributes(attributes)
|
||||||
|
|
@ -89,7 +87,7 @@ module RecurringTodos
|
||||||
|
|
||||||
def map_attributes
|
def map_attributes
|
||||||
# should be overwritten by subclasses to map attributes to activerecord model attributes
|
# should be overwritten by subclasses to map attributes to activerecord model attributes
|
||||||
@filterred_attributes
|
@filtered_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
# helper method to be used in mapped_attributes in subclasses
|
# helper method to be used in mapped_attributes in subclasses
|
||||||
|
|
@ -129,7 +127,7 @@ module RecurringTodos
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_tags
|
def save_tags
|
||||||
@recurring_todo.tag_with(@filterred_attributes[:tag_list]) if @filterred_attributes[:tag_list].present?
|
@recurring_todo.tag_with(@filtered_attributes[:tag_list]) if @filtered_attributes[:tag_list].present?
|
||||||
@recurring_todo.reload
|
@recurring_todo.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -145,7 +143,5 @@ module RecurringTodos
|
||||||
# avoid nil
|
# avoid nil
|
||||||
attributes[:tag_list].blank? ? "" : attributes[:tag_list].strip
|
attributes[:tag_list].blank? ? "" : attributes[:tag_list].strip
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class DailyRecurrencePattern < AbstractRecurrencePattern
|
class DailyRecurrencePattern < AbstractRecurrencePattern
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
super user
|
super user
|
||||||
end
|
end
|
||||||
|
|
@ -47,6 +45,5 @@ module RecurringTodos
|
||||||
return previous == nil ? start : start + every_x_days.day - 1.day
|
return previous == nil ? start : start + every_x_days.day - 1.day
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class DailyRecurringTodosBuilder < AbstractRecurringTodosBuilder
|
class DailyRecurringTodosBuilder < AbstractRecurringTodosBuilder
|
||||||
attr_reader :recurring_todo, :pattern
|
attr_reader :recurring_todo, :pattern
|
||||||
|
|
||||||
|
|
@ -29,7 +28,5 @@ module RecurringTodos
|
||||||
def valid_selector?(selector)
|
def valid_selector?(selector)
|
||||||
%w{daily_every_x_day daily_every_work_day}.include?(selector)
|
%w{daily_every_x_day daily_every_work_day}.include?(selector)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class MonthlyRecurrencePattern < AbstractRecurrencePattern
|
class MonthlyRecurrencePattern < AbstractRecurrencePattern
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
super user
|
super user
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class MonthlyRecurringTodosBuilder < AbstractRecurringTodosBuilder
|
class MonthlyRecurringTodosBuilder < AbstractRecurringTodosBuilder
|
||||||
attr_reader :recurring_todo
|
attr_reader :recurring_todo
|
||||||
|
|
||||||
|
|
@ -40,7 +39,5 @@ module RecurringTodos
|
||||||
def valid_selector?(selector)
|
def valid_selector?(selector)
|
||||||
%w{monthly_every_x_day monthly_every_xth_day}.include?(selector)
|
%w{monthly_every_x_day monthly_every_xth_day}.include?(selector)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class RecurringTodosBuilder
|
class RecurringTodosBuilder
|
||||||
|
|
||||||
attr_reader :builder, :project, :context, :tag_list, :user
|
attr_reader :builder, :project, :context, :tag_list, :user
|
||||||
|
|
||||||
def initialize (user, attributes)
|
def initialize (user, attributes)
|
||||||
|
|
@ -17,7 +15,7 @@ module RecurringTodos
|
||||||
|
|
||||||
def create_builder(selector)
|
def create_builder(selector)
|
||||||
raise "Unknown recurrence selector in :recurring_period (#{selector})" unless valid_selector? selector
|
raise "Unknown recurrence selector in :recurring_period (#{selector})" unless valid_selector? selector
|
||||||
eval("RecurringTodos::#{selector.capitalize}RecurringTodosBuilder.new(@user, @attributes)")
|
eval("RecurringTodos::#{selector.capitalize}RecurringTodosBuilder.new(@user, @attributes)", binding, __FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build
|
def build
|
||||||
|
|
@ -72,7 +70,5 @@ module RecurringTodos
|
||||||
def parse_context
|
def parse_context
|
||||||
@context, @new_context_created = @attributes.parse_collection(:context, @user.contexts)
|
@context, @new_context_created = @attributes.parse_collection(:context, @user.contexts)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class WeeklyRecurrencePattern < AbstractRecurrencePattern
|
class WeeklyRecurrencePattern < AbstractRecurrencePattern
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
super user
|
super user
|
||||||
end
|
end
|
||||||
|
|
@ -79,8 +77,5 @@ module RecurringTodos
|
||||||
end
|
end
|
||||||
-1
|
-1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class WeeklyRecurringTodosBuilder < AbstractRecurringTodosBuilder
|
class WeeklyRecurringTodosBuilder < AbstractRecurringTodosBuilder
|
||||||
attr_reader :recurring_todo
|
attr_reader :recurring_todo
|
||||||
|
|
||||||
|
|
@ -37,7 +36,5 @@ module RecurringTodos
|
||||||
def valid_selector?(key)
|
def valid_selector?(key)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class YearlyRecurrencePattern < AbstractRecurrencePattern
|
class YearlyRecurrencePattern < AbstractRecurrencePattern
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
super user
|
super user
|
||||||
end
|
end
|
||||||
|
|
@ -104,6 +102,5 @@ module RecurringTodos
|
||||||
|
|
||||||
the_next
|
the_next
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module RecurringTodos
|
module RecurringTodos
|
||||||
|
|
||||||
class YearlyRecurringTodosBuilder < AbstractRecurringTodosBuilder
|
class YearlyRecurringTodosBuilder < AbstractRecurringTodosBuilder
|
||||||
attr_reader :recurring_todo
|
attr_reader :recurring_todo
|
||||||
|
|
||||||
|
|
@ -39,7 +38,5 @@ module RecurringTodos
|
||||||
def get_every_other2
|
def get_every_other2
|
||||||
{ 0 => :yearly_month_of_year, 1 => :yearly_month_of_year2 }[get_recurrence_selector]
|
{ 0 => :yearly_month_of_year, 1 => :yearly_month_of_year2 }[get_recurrence_selector]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module Search
|
module Search
|
||||||
|
|
||||||
class SearchResults
|
class SearchResults
|
||||||
attr_reader :results
|
attr_reader :results
|
||||||
|
|
||||||
|
|
@ -27,16 +26,16 @@ module Search
|
||||||
|
|
||||||
def incomplete_todos(terms)
|
def incomplete_todos(terms)
|
||||||
@user.todos.
|
@user.todos.
|
||||||
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND todos.completed_at IS NULL", terms, terms).
|
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND todos.completed_at IS NULL", terms, terms)
|
||||||
includes(Todo::DEFAULT_INCLUDES).
|
.includes(Todo::DEFAULT_INCLUDES)
|
||||||
reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))
|
.reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def complete_todos(terms)
|
def complete_todos(terms)
|
||||||
@user.todos.
|
@user.todos.
|
||||||
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND NOT (todos.completed_at IS NULL)", terms, terms).
|
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND NOT (todos.completed_at IS NULL)", terms, terms)
|
||||||
includes(Todo::DEFAULT_INCLUDES).
|
.includes(Todo::DEFAULT_INCLUDES)
|
||||||
reorder("todos.completed_at DESC")
|
.reorder("todos.completed_at DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def todo_tags_by_name(terms)
|
def todo_tags_by_name(terms)
|
||||||
|
|
@ -48,7 +47,5 @@ module Search
|
||||||
"WHERE todos.user_id=? " +
|
"WHERE todos.user_id=? " +
|
||||||
"AND tags.name " + Common.like_operator + " ? ", @user.id, terms])
|
"AND tags.name " + Common.like_operator + " ? ", @user.id, terms])
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
module Stats
|
module Stats
|
||||||
class Actions
|
class Actions
|
||||||
|
SECONDS_PER_DAY = 86_400
|
||||||
SECONDS_PER_DAY = 86400;
|
|
||||||
|
|
||||||
attr_reader :user
|
attr_reader :user
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
@user = user
|
@user = user
|
||||||
|
|
||||||
|
|
@ -171,9 +171,9 @@ module Stats
|
||||||
# - actions not deferred (show_from must be null)
|
# - actions not deferred (show_from must be null)
|
||||||
# - actions not pending/blocked
|
# - actions not pending/blocked
|
||||||
|
|
||||||
@actions_running_time = @user.todos.not_completed.not_hidden.not_deferred_or_blocked.
|
@actions_running_time = @user.todos.not_completed.not_hidden.not_deferred_or_blocked
|
||||||
select("todos.created_at").
|
.select("todos.created_at")
|
||||||
reorder("todos.created_at DESC")
|
.reorder("todos.created_at DESC")
|
||||||
|
|
||||||
@max_weeks = difference_in_weeks(@today, @actions_running_time.last.created_at)
|
@max_weeks = difference_in_weeks(@today, @actions_running_time.last.created_at)
|
||||||
@actions_running_per_week_array = convert_to_weeks_from_today_array(@actions_running_time, @max_weeks + 1, :created_at)
|
@actions_running_per_week_array = convert_to_weeks_from_today_array(@actions_running_time, @max_weeks + 1, :created_at)
|
||||||
|
|
@ -202,9 +202,9 @@ module Stats
|
||||||
end
|
end
|
||||||
|
|
||||||
def open_per_week_data
|
def open_per_week_data
|
||||||
@actions_started = @user.todos.created_after(@today-53.weeks).
|
@actions_started = @user.todos.created_after(@today - 53.weeks)
|
||||||
select("todos.created_at, todos.completed_at").
|
.select("todos.created_at, todos.completed_at")
|
||||||
reorder("todos.created_at DESC")
|
.reorder("todos.created_at DESC")
|
||||||
|
|
||||||
@max_weeks = difference_in_weeks(@today, @actions_started.last.created_at)
|
@max_weeks = difference_in_weeks(@today, @actions_started.last.created_at)
|
||||||
|
|
||||||
|
|
@ -373,7 +373,7 @@ module Stats
|
||||||
a = []
|
a = []
|
||||||
start_week = difference_in_weeks(@today, record.created_at)
|
start_week = difference_in_weeks(@today, record.created_at)
|
||||||
end_week = record.completed_at ? difference_in_weeks(@today, record.completed_at) : 0
|
end_week = record.completed_at ? difference_in_weeks(@today, record.completed_at) : 0
|
||||||
end_week.upto(start_week) { |i| a << i };
|
end_week.upto(start_week) { |i| a << i }
|
||||||
return a
|
return a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
module Stats
|
module Stats
|
||||||
|
|
||||||
class Chart
|
class Chart
|
||||||
|
|
||||||
attr_reader :action, :height, :width
|
attr_reader :action, :height, :width
|
||||||
|
|
||||||
def initialize(action, dimensions = {})
|
def initialize(action, dimensions = {})
|
||||||
@action = action
|
@action = action
|
||||||
@height = dimensions.fetch(:height) { 250 }
|
@height = dimensions.fetch(:height) { 250 }
|
||||||
|
|
@ -12,7 +11,5 @@ module Stats
|
||||||
def dimensions
|
def dimensions
|
||||||
"#{width}x#{height}"
|
"#{width}x#{height}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module Stats
|
module Stats
|
||||||
class Contexts
|
class Contexts
|
||||||
|
|
||||||
attr_reader :user
|
attr_reader :user
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
@user = user
|
@user = user
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module Stats
|
module Stats
|
||||||
class Projects
|
class Projects
|
||||||
|
|
||||||
attr_reader :user
|
attr_reader :user
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
@user = user
|
@user = user
|
||||||
end
|
end
|
||||||
|
|
@ -24,6 +24,5 @@ module Stats
|
||||||
projects = user.projects.order('created_at ASC')
|
projects = user.projects.order('created_at ASC')
|
||||||
projects.sort_by{ |p| p.running_time }.reverse.take(10)
|
projects.sort_by{ |p| p.running_time }.reverse.take(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
# http://www.juixe.com/techknow/index.php/2006/07/15/acts-as-taggable-tag-cloud/
|
# http://www.juixe.com/techknow/index.php/2006/07/15/acts-as-taggable-tag-cloud/
|
||||||
module Stats
|
module Stats
|
||||||
class TagCloud
|
class TagCloud
|
||||||
|
|
||||||
attr_reader :levels, :tags
|
attr_reader :levels, :tags
|
||||||
|
|
||||||
def initialize(tags)
|
def initialize(tags)
|
||||||
@levels = 10
|
@levels = 10
|
||||||
@tags = tags.sort_by { |tag| tag.name.downcase }
|
@tags = tags.sort_by { |tag| tag.name.downcase }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module Stats
|
module Stats
|
||||||
class TagCloudQuery
|
class TagCloudQuery
|
||||||
|
|
||||||
attr_reader :user, :cutoff
|
attr_reader :user, :cutoff
|
||||||
|
|
||||||
def initialize(user, cutoff = nil)
|
def initialize(user, cutoff = nil)
|
||||||
@user = user
|
@user = user
|
||||||
@cutoff = cutoff
|
@cutoff = cutoff
|
||||||
|
|
@ -19,7 +19,7 @@ module Stats
|
||||||
|
|
||||||
def sql
|
def sql
|
||||||
# TODO: parameterize limit
|
# TODO: parameterize limit
|
||||||
query = "SELECT tags.id, tags.name AS name, count(*) AS count"
|
query = "SELECT tags.id, tags.name AS name, COUNT(*) AS count"
|
||||||
query << " FROM taggings, tags, todos"
|
query << " FROM taggings, tags, todos"
|
||||||
query << " WHERE tags.id = tag_id"
|
query << " WHERE tags.id = tag_id"
|
||||||
query << " AND todos.user_id = ? "
|
query << " AND todos.user_id = ? "
|
||||||
|
|
@ -33,6 +33,5 @@ module Stats
|
||||||
query << " ORDER BY count DESC, name "
|
query << " ORDER BY count DESC, name "
|
||||||
query << " LIMIT 100"
|
query << " LIMIT 100"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
module Stats
|
module Stats
|
||||||
class TimeToComplete
|
class TimeToComplete
|
||||||
|
SECONDS_PER_DAY = 86_400
|
||||||
SECONDS_PER_DAY = 86400;
|
|
||||||
|
|
||||||
attr_reader :actions
|
attr_reader :actions
|
||||||
|
|
||||||
def initialize(actions)
|
def initialize(actions)
|
||||||
@actions = actions
|
@actions = actions
|
||||||
end
|
end
|
||||||
|
|
@ -58,6 +58,5 @@ module Stats
|
||||||
def arbitrary_day
|
def arbitrary_day
|
||||||
@arbitrary_day ||= Time.utc(2000, 1, 1, 0, 0)
|
@arbitrary_day ||= Time.utc(2000, 1, 1, 0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
# and visible contexts will be included.
|
# and visible contexts will be included.
|
||||||
module Stats
|
module Stats
|
||||||
class TopContextsQuery
|
class TopContextsQuery
|
||||||
|
|
||||||
attr_reader :user, :running, :limit
|
attr_reader :user, :running, :limit
|
||||||
|
|
||||||
def initialize(user, options = {})
|
def initialize(user, options = {})
|
||||||
@user = user
|
@user = user
|
||||||
@running = options.fetch(:running) { false }
|
@running = options.fetch(:running) { false }
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
# or completed since that cutoff will be included.
|
# or completed since that cutoff will be included.
|
||||||
module Stats
|
module Stats
|
||||||
class TopProjectsQuery
|
class TopProjectsQuery
|
||||||
|
|
||||||
attr_reader :user, :cutoff
|
attr_reader :user, :cutoff
|
||||||
|
|
||||||
def initialize(user, cutoff = nil)
|
def initialize(user, cutoff = nil)
|
||||||
@user = user
|
@user = user
|
||||||
@cutoff = cutoff
|
@cutoff = cutoff
|
||||||
|
|
@ -34,6 +34,5 @@ module Stats
|
||||||
query << "ORDER BY count DESC "
|
query << "ORDER BY count DESC "
|
||||||
query << "LIMIT 10"
|
query << "LIMIT 10"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module Stats
|
module Stats
|
||||||
class Totals
|
class Totals
|
||||||
|
|
||||||
attr_reader :user
|
attr_reader :user
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
@user = user
|
@user = user
|
||||||
end
|
end
|
||||||
|
|
@ -83,6 +83,5 @@ module Stats
|
||||||
def tag_ids
|
def tag_ids
|
||||||
@tag_ids ||= Stats::UserTagsQuery.new(user).result.map(&:id)
|
@tag_ids ||= Stats::UserTagsQuery.new(user).result.map(&:id)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module Stats
|
module Stats
|
||||||
class UserStats
|
class UserStats
|
||||||
|
|
||||||
attr_reader :user
|
attr_reader :user
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
@user = user
|
@user = user
|
||||||
end
|
end
|
||||||
|
|
@ -38,6 +38,5 @@ module Stats
|
||||||
end
|
end
|
||||||
@tag_cloud_90days
|
@tag_cloud_90days
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module Stats
|
module Stats
|
||||||
class UserTagsQuery
|
class UserTagsQuery
|
||||||
|
|
||||||
attr_reader :user
|
attr_reader :user
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
@user = user
|
@user = user
|
||||||
end
|
end
|
||||||
|
|
@ -21,6 +21,5 @@ module Stats
|
||||||
AND todos.user_id = ?
|
AND todos.user_id = ?
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class Tag < ApplicationRecord
|
class Tag < ApplicationRecord
|
||||||
|
|
||||||
has_many :taggings
|
has_many :taggings
|
||||||
has_many :taggable, :through => :taggings
|
has_many :taggable, :through => :taggings
|
||||||
|
|
||||||
|
|
@ -29,5 +28,4 @@ class Tag < ApplicationRecord
|
||||||
def to_s
|
def to_s
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
# The Tagging join model.
|
# The Tagging join model.
|
||||||
|
|
||||||
class Tagging < ApplicationRecord
|
class Tagging < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :tag
|
belongs_to :tag
|
||||||
belongs_to :taggable, :polymorphic => true, :touch => true
|
belongs_to :taggable, :polymorphic => true, :touch => true
|
||||||
|
|
||||||
|
|
@ -13,5 +10,4 @@ class Tagging < ApplicationRecord
|
||||||
def delete_orphaned_tag
|
def delete_orphaned_tag
|
||||||
tag.destroy if tag and tag.taggings.count == 0
|
tag.destroy if tag and tag.taggings.count == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
class Todo < ApplicationRecord
|
class Todo < ApplicationRecord
|
||||||
|
|
||||||
MAX_DESCRIPTION_LENGTH = 300
|
MAX_DESCRIPTION_LENGTH = 300
|
||||||
MAX_NOTES_LENGTH = 60000
|
MAX_NOTES_LENGTH = 60_000
|
||||||
|
|
||||||
after_save :save_predecessors
|
after_save :save_predecessors
|
||||||
|
|
||||||
|
|
@ -36,10 +35,10 @@ class Todo < ApplicationRecord
|
||||||
scope :pending, -> { where 'todos.state = ?', 'pending' }
|
scope :pending, -> { where 'todos.state = ?', 'pending' }
|
||||||
scope :deferred_or_blocked, -> { where '(todos.state = ?) OR (todos.state = ?)', 'deferred', 'pending' }
|
scope :deferred_or_blocked, -> { where '(todos.state = ?) OR (todos.state = ?)', 'deferred', 'pending' }
|
||||||
scope :hidden, -> {
|
scope :hidden, -> {
|
||||||
joins('INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id').
|
joins('INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id')
|
||||||
joins('LEFT OUTER JOIN projects p_hidden ON p_hidden.id = todos.project_id').
|
.joins('LEFT OUTER JOIN projects p_hidden ON p_hidden.id = todos.project_id')
|
||||||
where('(c_hidden.state = ? OR p_hidden.state = ?)', 'hidden', 'hidden').
|
.where('(c_hidden.state = ? OR p_hidden.state = ?)', 'hidden', 'hidden')
|
||||||
where('NOT todos.state = ?', 'completed') }
|
.where('NOT todos.state = ?', 'completed') }
|
||||||
scope :not_hidden, -> { not_context_hidden.not_project_hidden }
|
scope :not_hidden, -> { not_context_hidden.not_project_hidden }
|
||||||
scope :not_deferred_or_blocked, -> { where '(NOT todos.state=?) AND (NOT todos.state = ?)', 'deferred', 'pending' }
|
scope :not_deferred_or_blocked, -> { where '(NOT todos.state=?) AND (NOT todos.state = ?)', 'deferred', 'pending' }
|
||||||
scope :not_project_hidden, -> { joins('LEFT OUTER JOIN projects p ON p.id = todos.project_id').where('p.id IS NULL OR NOT(p.state = ?)', 'hidden') }
|
scope :not_project_hidden, -> { joins('LEFT OUTER JOIN projects p ON p.id = todos.project_id').where('p.id IS NULL OR NOT(p.state = ?)', 'hidden') }
|
||||||
|
|
@ -50,12 +49,12 @@ class Todo < ApplicationRecord
|
||||||
scope :are_due, -> { where 'NOT (todos.due IS NULL)' }
|
scope :are_due, -> { where 'NOT (todos.due IS NULL)' }
|
||||||
scope :due_today, -> { where("todos.due <= ?", Time.zone.now) }
|
scope :due_today, -> { where("todos.due <= ?", Time.zone.now) }
|
||||||
scope :with_tag, lambda { |tag_id| joins("INNER JOIN taggings ON todos.id = taggings.taggable_id").where("taggings.tag_id = ? AND taggings.taggable_type='Todo'", tag_id) }
|
scope :with_tag, lambda { |tag_id| joins("INNER JOIN taggings ON todos.id = taggings.taggable_id").where("taggings.tag_id = ? AND taggings.taggable_type='Todo'", tag_id) }
|
||||||
scope :with_tags, lambda { |tag_ids| where("EXISTS(SELECT * from taggings t WHERE t.tag_id IN (?) AND t.taggable_id=todos.id AND t.taggable_type='Todo')", tag_ids) }
|
scope :with_tags, lambda { |tag_ids| where("EXISTS(SELECT * FROM taggings t WHERE t.tag_id IN (?) AND t.taggable_id=todos.id AND t.taggable_type='Todo')", tag_ids) }
|
||||||
scope :completed_after, lambda { |date| where("todos.completed_at > ?", date) }
|
scope :completed_after, lambda { |date| where("todos.completed_at > ?", date) }
|
||||||
scope :completed_before, lambda { |date| where("todos.completed_at < ?", date) }
|
scope :completed_before, lambda { |date| where("todos.completed_at < ?", date) }
|
||||||
scope :created_after, lambda { |date| where("todos.created_at > ?", date) }
|
scope :created_after, lambda { |date| where("todos.created_at > ?", date) }
|
||||||
scope :created_before, lambda { |date| where("todos.created_at < ?", date) }
|
scope :created_before, lambda { |date| where("todos.created_at < ?", date) }
|
||||||
scope :created_or_completed_after, lambda { |date| where("todos.created_at > ? or todos.completed_at > ?", date, date) }
|
scope :created_or_completed_after, lambda { |date| where("todos.created_at > ? OR todos.completed_at > ?", date, date) }
|
||||||
|
|
||||||
def self.due_after(date)
|
def self.due_after(date)
|
||||||
where('todos.due > ?', date)
|
where('todos.due > ?', date)
|
||||||
|
|
@ -73,7 +72,6 @@ class Todo < ApplicationRecord
|
||||||
aasm_initial_state = Proc.new { (self.show_from && self.user && (self.show_from > self.user.date)) ? :deferred : :active }
|
aasm_initial_state = Proc.new { (self.show_from && self.user && (self.show_from > self.user.date)) ? :deferred : :active }
|
||||||
|
|
||||||
aasm :column => :state do
|
aasm :column => :state do
|
||||||
|
|
||||||
state :active
|
state :active
|
||||||
state :completed, :before_enter => Proc.new { self.completed_at = Time.zone.now }, :before_exit => Proc.new { self.completed_at = nil }
|
state :completed, :before_enter => Proc.new { self.completed_at = Time.zone.now }, :before_exit => Proc.new { self.completed_at = nil }
|
||||||
state :deferred, :before_exit => Proc.new { self[:show_from] = nil }
|
state :deferred, :before_exit => Proc.new { self[:show_from] = nil }
|
||||||
|
|
@ -124,7 +122,7 @@ class Todo < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def no_uncompleted_predecessors_or_deferral?
|
def no_uncompleted_predecessors_or_deferral?
|
||||||
no_deferral = show_from.blank? or Time.zone.now > show_from
|
no_deferral = show_from.blank? || Time.zone.now > show_from
|
||||||
return (no_deferral && no_uncompleted_predecessors?)
|
return (no_deferral && no_uncompleted_predecessors?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -284,14 +282,14 @@ class Todo < ApplicationRecord
|
||||||
|
|
||||||
# activate todos that should be activated if the current todo is completed
|
# activate todos that should be activated if the current todo is completed
|
||||||
def activate_pending_todos
|
def activate_pending_todos
|
||||||
pending_todos = successors.select { |t| t.uncompleted_predecessors.empty? and !t.completed? }
|
pending_todos = successors.select { |t| t.uncompleted_predecessors.empty? && !t.completed? }
|
||||||
pending_todos.each { |t| t.activate! }
|
pending_todos.each { |t| t.activate! }
|
||||||
return pending_todos
|
return pending_todos
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return todos that should be blocked if the current todo is undone
|
# Return todos that should be blocked if the current todo is undone
|
||||||
def block_successors
|
def block_successors
|
||||||
active_successors = successors.select {|t| t.active? or t.deferred?}
|
active_successors = successors.select { |t| t.active? || t.deferred? }
|
||||||
active_successors.each { |t| t.block! }
|
active_successors.each { |t| t.block! }
|
||||||
return active_successors
|
return active_successors
|
||||||
end
|
end
|
||||||
|
|
@ -387,5 +385,4 @@ class Todo < ApplicationRecord
|
||||||
|
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
module Todos
|
module Todos
|
||||||
class Calendar
|
class Calendar
|
||||||
|
|
||||||
attr_reader :user, :included_tables
|
attr_reader :user, :included_tables
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
|
|
@ -53,6 +52,5 @@ module Todos
|
||||||
def actions
|
def actions
|
||||||
user.todos.not_completed.includes(included_tables).reorder("due")
|
user.todos.not_completed.includes(included_tables).reorder("due")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ module Todos
|
||||||
end
|
end
|
||||||
|
|
||||||
not_done_todos = not_done_todos.
|
not_done_todos = not_done_todos.
|
||||||
reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC")).
|
reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))
|
||||||
includes(Todo::DEFAULT_INCLUDES)
|
.includes(Todo::DEFAULT_INCLUDES)
|
||||||
|
|
||||||
not_done_todos = not_done_todos.limit(sanitize(params[:limit])) if params[:limit]
|
not_done_todos = not_done_todos.limit(sanitize(params[:limit])) if params[:limit]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,8 @@ class User < ApplicationRecord
|
||||||
dependent: :delete_all
|
dependent: :delete_all
|
||||||
|
|
||||||
has_many(:deferred_todos,
|
has_many(:deferred_todos,
|
||||||
-> { where('state = ?', 'deferred').
|
-> { where('state = ?', 'deferred')
|
||||||
order('show_from ASC, todos.created_at DESC')},
|
.order('show_from ASC, todos.created_at DESC') },
|
||||||
:class_name => 'Todo') do
|
:class_name => 'Todo') do
|
||||||
def find_and_activate_ready
|
def find_and_activate_ready
|
||||||
where('show_from <= ?', Time.current).collect { |t| t.activate! }
|
where('show_from <= ?', Time.current).collect { |t| t.activate! }
|
||||||
|
|
@ -218,5 +218,4 @@ protected
|
||||||
taggings = Tagging.where(taggable_id: ids).pluck(:id)
|
taggings = Tagging.where(taggable_id: ids).pluck(:id)
|
||||||
Tagging.where(id: taggings).delete_all
|
Tagging.where(id: taggings).delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -72,5 +72,4 @@ class RichMessageExtractor
|
||||||
def fix_date_string yymmdd
|
def fix_date_string yymmdd
|
||||||
"20#{yymmdd[0..1]}-#{yymmdd[2..3]}-#{yymmdd[4..5]} 00:00"
|
"20#{yymmdd[0..1]}-#{yymmdd[2..3]}-#{yymmdd[4..5]} 00:00"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class TodoFromRichMessage
|
class TodoFromRichMessage
|
||||||
|
|
||||||
attr_reader :user, :default_context_id, :description, :notes
|
attr_reader :user, :default_context_id, :description, :notes
|
||||||
|
|
||||||
def initialize(user, default_context_id, description, notes)
|
def initialize(user, default_context_id, description, notes)
|
||||||
|
|
@ -21,8 +20,9 @@ class TodoFromRichMessage
|
||||||
|
|
||||||
context_id = default_context_id
|
context_id = default_context_id
|
||||||
if context.present?
|
if context.present?
|
||||||
found_context = user.contexts.active.where("name like ?", "%#{context}%").first
|
# TODO: Should this use ILIKE on Postgres?
|
||||||
found_context = user.contexts.where("name like ?", "%#{context}%").first if !found_context
|
found_context = user.contexts.active.where("name LIKE ?", "%#{context}%").first
|
||||||
|
found_context = user.contexts.where("name LIKE ?", "%#{context}%").first if !found_context
|
||||||
context_id = found_context.id if found_context
|
context_id = found_context.id if found_context
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,4 @@ require "dispatcher"
|
||||||
|
|
||||||
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
|
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
|
||||||
Dispatcher.dispatch
|
Dispatcher.dispatch
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue