Code style fixes

This commit is contained in:
Jyri-Petteri Paloposki 2020-10-10 02:27:42 +03:00
parent c6bbc67dab
commit d8acf60049
72 changed files with 458 additions and 594 deletions

View file

@ -1,5 +1,4 @@
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 :recurring_todos, :dependent => :delete_all
belongs_to :user
@ -15,7 +14,6 @@ class Context < ApplicationRecord
include AASM
aasm :column => :state do
state :active, :initial => true
state :closed
state :hidden
@ -48,11 +46,9 @@ class Context < ApplicationRecord
def no_active_todos?
return todos.active.count == 0
end
end
class NullContext
def nil?
true
end
@ -64,5 +60,4 @@ class NullContext
def name
''
end
end

View file

@ -1,17 +1,13 @@
class Dependency < ApplicationRecord
# 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 :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
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)
end
end
end

View file

@ -1,5 +1,4 @@
class MessageGateway < ActionMailer::Base
def receive(email)
user = get_receiving_user_from_email_address(email)
return false if user.nil?

View file

@ -3,11 +3,11 @@ class Preference < ApplicationRecord
belongs_to :sms_context, :class_name => 'Context'
def self.themes
{ :black => 'black', :light_blue => 'light_blue'}
{ :black => 'black', :light_blue => 'light_blue' }
end
def self.due_styles
{ :due_in_n_days => 0, :due_on => 1}
{ :due_in_n_days => 0, :due_on => 1 }
end
def hide_completed_actions?
@ -29,8 +29,7 @@ class Preference < ApplicationRecord
date.in_time_zone(time_zone).beginning_of_day
end
def format_date (date)
def format_date(date)
return date ? date.in_time_zone(time_zone).strftime("#{date_format}") : ''
end
end

View file

@ -1,6 +1,6 @@
class Project < ApplicationRecord
has_many :todos, -> {order(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))}, dependent: :delete_all
has_many :notes, -> {order "created_at DESC"}, dependent: :delete_all
has_many :todos, -> { order(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC")) }, dependent: :delete_all
has_many :notes, -> { order "created_at DESC" }, dependent: :delete_all
has_many :recurring_todos
belongs_to :default_context, :class_name => "Context", :foreign_key => "default_context_id"
@ -25,7 +25,6 @@ class Project < ApplicationRecord
include AASM
aasm :column => :state do
state :active, :initial => true
state :hidden
state :completed, :enter => :set_completed_at_date, :exit => :clear_completed_at_date
@ -145,11 +144,9 @@ class Project < ApplicationRecord
end
count
end
end
class NullProject
def hidden?
false
end
@ -169,5 +166,4 @@ class NullProject
def persisted?
false
end
end

View file

@ -5,8 +5,8 @@ class RecurringTodo < ApplicationRecord
has_many :todos
scope :active, -> { where state: 'active'}
scope :completed, -> { where state: 'completed'}
scope :active, -> { where state: 'active' }
scope :completed, -> { where state: 'completed' }
include IsTaggable
@ -27,7 +27,7 @@ class RecurringTodo < ApplicationRecord
validates_presence_of :description, :recurring_period, :target, :ends_on, :context
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 :pattern_specific_validations
@ -72,7 +72,7 @@ class RecurringTodo < ApplicationRecord
def pattern
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)
end
@pattern
@ -138,5 +138,4 @@ class RecurringTodo < ApplicationRecord
def continues_recurring?(previous)
pattern.continues_recurring?(previous)
end
end

View file

@ -1,7 +1,5 @@
module RecurringTodos
class AbstractRecurrencePattern
attr_accessor :attributes
def initialize(user)
@ -147,7 +145,7 @@ module RecurringTodos
# checks if the next todos should be put in the tickler for recurrence_target == 'due_date'
def put_in_tickler?
!( show_always? || show_from_delta.nil?)
!(show_always? || show_from_delta.nil?)
end
def get_next_date(previous)
@ -207,14 +205,14 @@ module RecurringTodos
end
def find_xth_day_of_month(x, weekday, month, year)
start = Time.zone.local(year,month,1)
start = Time.zone.local(year, month, 1)
n = x
while n > 0
while start.wday() != weekday
start += 1.day
end
n -= 1
start += 1.day unless n==0
start += 1.day unless n == 0
end
start
end

View file

@ -1,20 +1,18 @@
module RecurringTodos
class AbstractRecurringTodosBuilder
attr_reader :mapped_attributes, :pattern
def initialize(user, attributes, pattern_class)
@user = user
@saved = false
@attributes = attributes
@selector = get_selector(selector_key)
@filterred_attributes = filter_attributes(@attributes)
@mapped_attributes = map_attributes(@filterred_attributes)
@attributes = attributes
@selector = get_selector(selector_key)
@filtered_attributes = filter_attributes(@attributes)
@mapped_attributes = map_attributes(@filtered_attributes)
@pattern = pattern_class.new(user)
@pattern.attributes = @mapped_attributes
@pattern = pattern_class.new(user)
@pattern.attributes = @mapped_attributes
end
# build does not add tags. For tags, the recurring todos needs to be saved
@ -60,36 +58,36 @@ module RecurringTodos
def filter_attributes(attributes)
# get pattern independend attributes
filterred_attributes = filter_generic_attributes(attributes)
filtered_attributes = filter_generic_attributes(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
def filter_generic_attributes(attributes)
return Tracks::AttributeHandler.new(@user, {
recurring_period: attributes[:recurring_period],
description: attributes[:description],
notes: attributes[:notes],
tag_list: tag_list_or_empty_string(attributes),
start_from: attributes[:start_from],
end_date: attributes[:end_date],
ends_on: attributes[:ends_on],
recurring_period: attributes[:recurring_period],
description: attributes[:description],
notes: attributes[:notes],
tag_list: tag_list_or_empty_string(attributes),
start_from: attributes[:start_from],
end_date: attributes[:end_date],
ends_on: attributes[:ends_on],
number_of_occurrences: attributes[:number_of_occurrences],
project: attributes[:project],
context: attributes[:context],
project_id: attributes[:project_id],
context_id: attributes[:context_id],
target: attributes[:recurring_target],
show_from_delta: attributes[:recurring_show_days_before],
show_always: attributes[:recurring_show_always]
project: attributes[:project],
context: attributes[:context],
project_id: attributes[:project_id],
context_id: attributes[:context_id],
target: attributes[:recurring_target],
show_from_delta: attributes[:recurring_show_days_before],
show_always: attributes[:recurring_show_always]
})
end
def map_attributes
# should be overwritten by subclasses to map attributes to activerecord model attributes
@filterred_attributes
@filtered_attributes
end
# helper method to be used in mapped_attributes in subclasses
@ -129,7 +127,7 @@ module RecurringTodos
end
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
end
@ -145,7 +143,5 @@ module RecurringTodos
# avoid nil
attributes[:tag_list].blank? ? "" : attributes[:tag_list].strip
end
end
end

View file

@ -1,7 +1,5 @@
module RecurringTodos
class DailyRecurrencePattern < AbstractRecurrencePattern
def initialize(user)
super user
end
@ -44,9 +42,8 @@ module RecurringTodos
else
# if there was no previous todo, do not add n: the first todo starts on
# today or on start_from
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

View file

@ -1,5 +1,4 @@
module RecurringTodos
class DailyRecurringTodosBuilder < AbstractRecurringTodosBuilder
attr_reader :recurring_todo, :pattern
@ -19,7 +18,7 @@ module RecurringTodos
def only_work_days?(daily_selector)
{ 'daily_every_x_day' => false,
'daily_every_work_day' => true}[daily_selector]
'daily_every_work_day' => true }[daily_selector]
end
def selector_key
@ -29,7 +28,5 @@ module RecurringTodos
def valid_selector?(selector)
%w{daily_every_x_day daily_every_work_day}.include?(selector)
end
end
end

View file

@ -1,7 +1,5 @@
module RecurringTodos
class MonthlyRecurrencePattern < AbstractRecurrencePattern
def initialize(user)
super user
end

View file

@ -1,5 +1,4 @@
module RecurringTodos
class MonthlyRecurringTodosBuilder < AbstractRecurringTodosBuilder
attr_reader :recurring_todo
@ -26,7 +25,7 @@ module RecurringTodos
end
def get_recurrence_selector
@selector=='monthly_every_x_day' ? 0 : 1
@selector == 'monthly_every_x_day' ? 0 : 1
end
def get_every_other2
@ -40,7 +39,5 @@ module RecurringTodos
def valid_selector?(selector)
%w{monthly_every_x_day monthly_every_xth_day}.include?(selector)
end
end
end

View file

@ -1,7 +1,5 @@
module RecurringTodos
class RecurringTodosBuilder
attr_reader :builder, :project, :context, :tag_list, :user
def initialize (user, attributes)
@ -17,7 +15,7 @@ module RecurringTodos
def create_builder(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
def build
@ -72,7 +70,5 @@ module RecurringTodos
def parse_context
@context, @new_context_created = @attributes.parse_collection(:context, @user.contexts)
end
end
end
end

View file

@ -1,7 +1,5 @@
module RecurringTodos
class WeeklyRecurrencePattern < AbstractRecurrencePattern
def initialize(user)
super user
end
@ -31,7 +29,7 @@ module RecurringTodos
def validate
super
validate_not_blank(every_x_week, "Every other nth week may not be empty for weekly recurrence setting")
something_set = %w{sunday monday tuesday wednesday thursday friday saturday}.inject(false) { |set, day| set || self.send("on_#{day}") }
something_set = %w{ sunday monday tuesday wednesday thursday friday saturday }.inject(false) { |set, day| set || self.send("on_#{day}") }
errors[:base] << "You must specify at least one day on which the todo recurs" unless something_set
end
@ -61,7 +59,7 @@ module RecurringTodos
if start.wday() == 0
# we went to a new week, go to the nth next week and find first match
# that week. Note that we already went into the next week, so -1
start += (every_x_week-1).week
start += (every_x_week - 1).week
end
unless self.start_from.nil?
# check if the start_from date is later than previous. If so, use
@ -75,12 +73,9 @@ module RecurringTodos
def find_first_day_in_this_week(start)
# check if there are any days left this week for the next todo
start.wday().upto 6 do |i|
return start + (i-start.wday()).days if on_xday(i)
return start + (i - start.wday()).days if on_xday(i)
end
-1
end
end
end

View file

@ -1,5 +1,4 @@
module RecurringTodos
class WeeklyRecurringTodosBuilder < AbstractRecurringTodosBuilder
attr_reader :recurring_todo
@ -8,7 +7,7 @@ module RecurringTodos
end
def attributes_to_filter
%w{weekly_selector weekly_every_x_week} + %w{monday tuesday wednesday thursday friday saturday sunday}.map{|day| "weekly_return_#{day}" }
%w{ weekly_selector weekly_every_x_week } + %w{ monday tuesday wednesday thursday friday saturday sunday }.map{ |day| "weekly_return_#{day}" }
end
def map_attributes(mapping)
@ -26,7 +25,7 @@ module RecurringTodos
mapping.set_if_nil(key, ' ') # avoid nil
mapping.set_if_nil(source_key, ' ') # avoid nil
mapping.set(key, mapping.get(key)[0, index] + mapping.get(source_key) + mapping.get(key)[index+1, mapping.get(key).length])
mapping.set(key, mapping.get(key)[0, index] + mapping.get(source_key) + mapping.get(key)[index + 1, mapping.get(key).length])
mapping.except(source_key)
end
@ -37,7 +36,5 @@ module RecurringTodos
def valid_selector?(key)
true
end
end
end

View file

@ -1,7 +1,5 @@
module RecurringTodos
class YearlyRecurrencePattern < AbstractRecurrencePattern
def initialize(user)
super user
end
@ -104,6 +102,5 @@ module RecurringTodos
the_next
end
end
end

View file

@ -1,5 +1,4 @@
module RecurringTodos
class YearlyRecurringTodosBuilder < AbstractRecurringTodosBuilder
attr_reader :recurring_todo
@ -39,7 +38,5 @@ module RecurringTodos
def get_every_other2
{ 0 => :yearly_month_of_year, 1 => :yearly_month_of_year2 }[get_recurrence_selector]
end
end
end

View file

@ -1,5 +1,4 @@
module Search
class SearchResults
attr_reader :results
@ -27,28 +26,26 @@ module Search
def incomplete_todos(terms)
@user.todos.
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND todos.completed_at IS NULL", terms, terms).
includes(Todo::DEFAULT_INCLUDES).
reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND todos.completed_at IS NULL", terms, terms)
.includes(Todo::DEFAULT_INCLUDES)
.reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))
end
def complete_todos(terms)
@user.todos.
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).
reorder("todos.completed_at DESC")
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)
.reorder("todos.completed_at DESC")
end
def todo_tags_by_name(terms)
Tagging.find_by_sql([
"SELECT DISTINCT tags.name as name "+
"FROM tags "+
"LEFT JOIN taggings ON tags.id = taggings.tag_id "+
"LEFT JOIN todos ON taggings.taggable_id = todos.id "+
"WHERE todos.user_id=? "+
"AND tags.name " + Common.like_operator + " ? ", @user.id, terms])
"SELECT DISTINCT tags.name as name " +
"FROM tags " +
"LEFT JOIN taggings ON tags.id = taggings.tag_id " +
"LEFT JOIN todos ON taggings.taggable_id = todos.id " +
"WHERE todos.user_id=? " +
"AND tags.name " + Common.like_operator + " ? ", @user.id, terms])
end
end
end

View file

@ -1,9 +1,9 @@
module Stats
class Actions
SECONDS_PER_DAY = 86400;
SECONDS_PER_DAY = 86_400
attr_reader :user
def initialize(user)
@user = user
@ -58,17 +58,17 @@ module Stats
@interpolated_actions_created_this_month = interpolate_avg_for_current_month(@actions_created_last12months_array)
@interpolated_actions_done_this_month = interpolate_avg_for_current_month(@actions_done_last12months_array)
@created_count_array = Array.new(13, actions_last12months.created_after(@cut_off_year).count(:all)/12.0)
@done_count_array = Array.new(13, actions_last12months.completed_after(@cut_off_year).count(:all)/12.0)
@created_count_array = Array.new(13, actions_last12months.created_after(@cut_off_year).count(:all) / 12.0)
@done_count_array = Array.new(13, actions_last12months.completed_after(@cut_off_year).count(:all) / 12.0)
return {
datasets: [
{label: I18n.t('stats.labels.avg_created'), data: @created_count_array, type: "line"},
{label: I18n.t('stats.labels.avg_completed'), data: @done_count_array, type: "line"},
{label: I18n.t('stats.labels.month_avg_completed', :months => 3), data: @actions_done_avg_last12months_array, type: "line"},
{label: I18n.t('stats.labels.month_avg_created', :months => 3), data: @actions_created_avg_last12months_array, type: "line"},
{label: I18n.t('stats.labels.created'), data: @actions_created_last12months_array},
{label: I18n.t('stats.labels.completed'), data: @actions_done_last12months_array},
{ label: I18n.t('stats.labels.avg_created'), data: @created_count_array, type: "line" },
{ label: I18n.t('stats.labels.avg_completed'), data: @done_count_array, type: "line" },
{ label: I18n.t('stats.labels.month_avg_completed', :months => 3), data: @actions_done_avg_last12months_array, type: "line" },
{ label: I18n.t('stats.labels.month_avg_created', :months => 3), data: @actions_created_avg_last12months_array, type: "line" },
{ label: I18n.t('stats.labels.created'), data: @actions_created_last12months_array },
{ label: I18n.t('stats.labels.completed'), data: @actions_done_last12months_array },
],
labels: array_of_month_labels(@done_count_array.size),
}
@ -86,17 +86,17 @@ module Stats
# find max for graph in both hashes
@max = [@actions_done_last30days_array.max, @actions_created_last30days_array.max].max
created_count_array = Array.new(30){ |i| @actions_created_last30days.size/30.0 }
done_count_array = Array.new(30){ |i| @actions_done_last30days.size/30.0 }
created_count_array = Array.new(30) { |i| @actions_created_last30days.size / 30.0 }
done_count_array = Array.new(30) { |i| @actions_done_last30days.size / 30.0 }
# TODO: make the strftime i18n proof
time_labels = Array.new(30){ |i| I18n.l(Time.zone.now-i.days, :format => :stats) }
time_labels = Array.new(30) { |i| I18n.l(Time.zone.now-i.days, :format => :stats) }
return {
datasets: [
{label: I18n.t('stats.labels.avg_created'), data: created_count_array, type: "line"},
{label: I18n.t('stats.labels.avg_completed'), data: done_count_array, type: "line"},
{label: I18n.t('stats.labels.created'), data: @actions_created_last30days_array},
{label: I18n.t('stats.labels.completed'), data: @actions_done_last30days_array},
{ label: I18n.t('stats.labels.avg_created'), data: created_count_array, type: "line" },
{ label: I18n.t('stats.labels.avg_completed'), data: done_count_array, type: "line" },
{ label: I18n.t('stats.labels.created'), data: @actions_created_last30days_array },
{ label: I18n.t('stats.labels.completed'), data: @actions_done_last30days_array },
],
labels: time_labels,
}
@ -119,14 +119,14 @@ module Stats
# get percentage done cumulative
@cum_percent_done = convert_to_cumulative_array(@actions_completion_time_array, @actions_completion_time.count(:all))
time_labels = Array.new(@count){ |i| "#{i}-#{i+1}" }
time_labels = Array.new(@count) { |i| "#{i}-#{i+1}" }
time_labels[0] = I18n.t('stats.within_one')
time_labels[@count] = "> #{@count}"
return {
datasets: [
{label: I18n.t('stats.legend.percentage'), data: @cum_percent_done, type: "line"},
{label: I18n.t('stats.legend.actions'), data: @actions_completion_time_array},
{ label: I18n.t('stats.legend.percentage'), data: @cum_percent_done, type: "line" },
{ label: I18n.t('stats.legend.actions'), data: @actions_completion_time_array },
],
labels: time_labels,
}
@ -149,14 +149,14 @@ module Stats
# get percentage done cumulative
@cum_percent_done = convert_to_cumulative_array(@actions_running_time_array, @actions_running_time.count )
time_labels = Array.new(@count){ |i| "#{i}-#{i+1}" }
time_labels = Array.new(@count) { |i| "#{i}-#{i+1}" }
time_labels[0] = "< 1"
time_labels[@count] = "> #{@count}"
return {
datasets: [
{label: I18n.t('stats.running_time_all_legend.percentage'), data: @cum_percent_done, type: "line"},
{label: I18n.t('stats.running_time_all_legend.actions'), data: @actions_running_time_array},
{ label: I18n.t('stats.running_time_all_legend.percentage'), data: @cum_percent_done, type: "line" },
{ label: I18n.t('stats.running_time_all_legend.actions'), data: @actions_running_time_array },
],
labels: time_labels,
}
@ -171,12 +171,12 @@ module Stats
# - actions not deferred (show_from must be null)
# - actions not pending/blocked
@actions_running_time = @user.todos.not_completed.not_hidden.not_deferred_or_blocked.
select("todos.created_at").
reorder("todos.created_at DESC")
@actions_running_time = @user.todos.not_completed.not_hidden.not_deferred_or_blocked
.select("todos.created_at")
.reorder("todos.created_at DESC")
@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)
# cut off chart at 52 weeks = one year
@count = [52, @max_weeks].min
@ -188,23 +188,23 @@ module Stats
# get percentage done cumulative
@cum_percent_done = convert_to_cumulative_array(@actions_running_time_array, @actions_running_time.count )
time_labels = Array.new(@count){ |i| "#{i}-#{i+1}" }
time_labels = Array.new(@count) { |i| "#{i}-#{i+1}" }
time_labels[0] = "< 1"
time_labels[@count] = "> #{@count}"
return {
datasets: [
{label: I18n.t('stats.running_time_legend.percentage'), data: @cum_percent_done, type: "line"},
{label: I18n.t('stats.running_time_legend.actions'), data: @actions_running_time_array},
{ label: I18n.t('stats.running_time_legend.percentage'), data: @cum_percent_done, type: "line" },
{ label: I18n.t('stats.running_time_legend.actions'), data: @actions_running_time_array },
],
labels: time_labels,
}
end
def open_per_week_data
@actions_started = @user.todos.created_after(@today-53.weeks).
select("todos.created_at, todos.completed_at").
reorder("todos.created_at DESC")
@actions_started = @user.todos.created_after(@today - 53.weeks)
.select("todos.created_at, todos.completed_at")
.reorder("todos.created_at DESC")
@max_weeks = difference_in_weeks(@today, @actions_started.last.created_at)
@ -214,12 +214,12 @@ module Stats
@actions_open_per_week_array = convert_to_weeks_running_from_today_array(@actions_started, @max_weeks+1)
@actions_open_per_week_array = cut_off_array(@actions_open_per_week_array, @count)
time_labels = Array.new(@count+1){ |i| "#{i}-#{i+1}" }
time_labels[0] = "< 1"
time_labels = Array.new(@count+1) { |i| "#{i}-#{i+1}" }
time_labels[0] = "< 1"
return {
datasets: [
{label: I18n.t('stats.open_per_week_legend.actions'), data: @actions_open_per_week_array},
{ label: I18n.t('stats.open_per_week_legend.actions'), data: @actions_open_per_week_array },
],
labels: time_labels,
}
@ -230,18 +230,18 @@ module Stats
@actions_completion_day = @user.todos.completed.select("completed_at")
# convert to array and fill in non-existing days
@actions_creation_day_array = Array.new(7) { |i| 0}
@actions_creation_day.each { |t| @actions_creation_day_array[ t.created_at.wday ] += 1 }
@actions_creation_day_array = Array.new(7) { |i| 0 }
@actions_creation_day.each { |t| @actions_creation_day_array[t.created_at.wday] += 1 }
@max = @actions_creation_day_array.max
# convert to array and fill in non-existing days
@actions_completion_day_array = Array.new(7) { |i| 0}
@actions_completion_day.each { |t| @actions_completion_day_array[ t.completed_at.wday ] += 1 }
@actions_completion_day_array = Array.new(7) { |i| 0 }
@actions_completion_day.each { |t| @actions_completion_day_array[t.completed_at.wday] += 1 }
return {
datasets: [
{label: I18n.t('stats.labels.created'), data: @actions_creation_day_array},
{label: I18n.t('stats.labels.completed'), data: @actions_completion_day_array},
{ label: I18n.t('stats.labels.created'), data: @actions_creation_day_array },
{ label: I18n.t('stats.labels.completed'), data: @actions_completion_day_array },
],
labels: I18n.t('date.day_names'),
}
@ -253,17 +253,17 @@ module Stats
# convert to hash to be able to fill in non-existing days
@max=0
@actions_creation_day_array = Array.new(7) { |i| 0}
@actions_creation_day.each { |r| @actions_creation_day_array[ r.created_at.wday ] += 1 }
@actions_creation_day_array = Array.new(7) { |i| 0 }
@actions_creation_day.each { |r| @actions_creation_day_array[r.created_at.wday] += 1 }
# convert to hash to be able to fill in non-existing days
@actions_completion_day_array = Array.new(7) { |i| 0}
@actions_completion_day_array = Array.new(7) { |i| 0 }
@actions_completion_day.each { |r| @actions_completion_day_array[r.completed_at.wday] += 1 }
return {
datasets: [
{label: I18n.t('stats.labels.created'), data: @actions_creation_day_array},
{label: I18n.t('stats.labels.completed'), data: @actions_completion_day_array},
{ label: I18n.t('stats.labels.created'), data: @actions_creation_day_array },
{ label: I18n.t('stats.labels.completed'), data: @actions_completion_day_array },
],
labels: I18n.t('date.day_names'),
}
@ -274,17 +274,17 @@ module Stats
@actions_completion_hour = @user.todos.completed.select("completed_at")
# convert to hash to be able to fill in non-existing days
@actions_creation_hour_array = Array.new(24) { |i| 0}
@actions_creation_hour_array = Array.new(24) { |i| 0 }
@actions_creation_hour.each{|r| @actions_creation_hour_array[r.created_at.hour] += 1 }
# convert to hash to be able to fill in non-existing days
@actions_completion_hour_array = Array.new(24) { |i| 0}
@actions_completion_hour_array = Array.new(24) { |i| 0 }
@actions_completion_hour.each{|r| @actions_completion_hour_array[r.completed_at.hour] += 1 }
return {
datasets: [
{label: I18n.t('stats.labels.created'), data: @actions_creation_hour_array},
{label: I18n.t('stats.labels.completed'), data: @actions_completion_hour_array},
{ label: I18n.t('stats.labels.created'), data: @actions_creation_hour_array },
{ label: I18n.t('stats.labels.completed'), data: @actions_completion_hour_array },
],
labels: @actions_creation_hour_array.each_with_index.map { |total, hour| [hour] },
}
@ -295,17 +295,17 @@ module Stats
@actions_completion_hour = @user.todos.completed_after(@cut_off_month).select("completed_at")
# convert to hash to be able to fill in non-existing days
@actions_creation_hour_array = Array.new(24) { |i| 0}
@actions_creation_hour_array = Array.new(24) { |i| 0 }
@actions_creation_hour.each{|r| @actions_creation_hour_array[r.created_at.hour] += 1 }
# convert to hash to be able to fill in non-existing days
@actions_completion_hour_array = Array.new(24) { |i| 0}
@actions_completion_hour_array = Array.new(24) { |i| 0 }
@actions_completion_hour.each{|r| @actions_completion_hour_array[r.completed_at.hour] += 1 }
return {
datasets: [
{label: I18n.t('stats.labels.created'), data: @actions_creation_hour_array},
{label: I18n.t('stats.labels.completed'), data: @actions_completion_hour_array},
{ label: I18n.t('stats.labels.created'), data: @actions_creation_hour_array },
{ label: I18n.t('stats.labels.completed'), data: @actions_completion_hour_array },
],
labels: @actions_creation_hour_array.each_with_index.map { |total, hour| [hour] },
}
@ -334,7 +334,7 @@ module Stats
end
def interpolate_avg_for_current_month(set)
(set[0]*(1/percent_of_month) + set[1] + set[2]) / 3.0
(set[0] * (1 / percent_of_month) + set[1] + set[2]) / 3.0
end
def percent_of_month
@ -350,15 +350,15 @@ module Stats
end
def put_events_into_month_buckets(records, array_size, date_method_on_todo)
convert_to_array(records.select { |x| x.send(date_method_on_todo) }, array_size) { |r| [difference_in_months(@today, r.send(date_method_on_todo))]}
convert_to_array(records.select { |x| x.send(date_method_on_todo) }, array_size) { |r| [difference_in_months(@today, r.send(date_method_on_todo))] }
end
def convert_to_days_from_today_array(records, array_size, date_method_on_todo)
return convert_to_array(records, array_size){ |r| [difference_in_days(@today, r.send(date_method_on_todo))]}
return convert_to_array(records, array_size) { |r| [difference_in_days(@today, r.send(date_method_on_todo))] }
end
def convert_to_weeks_from_today_array(records, array_size, date_method_on_todo)
return convert_to_array(records, array_size) { |r| [difference_in_weeks(@today, r.send(date_method_on_todo))]}
return convert_to_array(records, array_size) { |r| [difference_in_weeks(@today, r.send(date_method_on_todo))] }
end
def convert_to_weeks_running_array(records, array_size)
@ -373,37 +373,37 @@ module Stats
a = []
start_week = difference_in_weeks(@today, record.created_at)
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
end
def cut_off_array_with_sum(array, cut_off)
# +1 to hold sum of rest
a = Array.new(cut_off+1){|i| array[i]||0}
a = Array.new(cut_off + 1) { |i| array[i] || 0 }
# add rest of array to last elem
a[cut_off] += array.inject(:+) - a.inject(:+)
return a
end
def cut_off_array(array, cut_off)
return Array.new(cut_off){|i| array[i]||0}
return Array.new(cut_off) { |i| array[i] || 0 }
end
def convert_to_cumulative_array(array, max)
# calculate fractions
a = Array.new(array.size){|i| array[i]*100.0/max}
a = Array.new(array.size) {|i| array[i] * 100.0 / max}
# make cumulative
1.upto(array.size-1){ |i| a[i] += a[i-1] }
1.upto(array.size-1) { |i| a[i] += a[i - 1] }
return a
end
def difference_in_months(date1, date2)
return (date1.utc.year - date2.utc.year)*12 + (date1.utc.month - date2.utc.month)
return (date1.utc.year - date2.utc.year) * 12 + (date1.utc.month - date2.utc.month)
end
# assumes date1 > date2
def difference_in_days(date1, date2)
return ((date1.utc.at_midnight-date2.utc.at_midnight)/SECONDS_PER_DAY).to_i
return ((date1.utc.at_midnight - date2.utc.at_midnight) / SECONDS_PER_DAY).to_i
end
# assumes date1 > date2
@ -412,23 +412,23 @@ module Stats
end
def three_month_avg(set, i)
(set.fetch(i){ 0 } + set.fetch(i+1){ 0 } + set.fetch(i+2){ 0 }) / 3.0
(set.fetch(i) { 0 } + set.fetch(i+1) { 0 } + set.fetch(i + 2) { 0 }) / 3.0
end
def set_three_month_avg(set,upper_bound)
(0..upper_bound-1).map { |i| three_month_avg(set, i) }
def set_three_month_avg(set, upper_bound)
(0..upper_bound - 1).map { |i| three_month_avg(set, i) }
end
def compute_running_avg_array(set, upper_bound)
result = set_three_month_avg(set, upper_bound)
result[upper_bound-1] = result[upper_bound-1] * 3 if upper_bound == set.length
result[upper_bound-2] = result[upper_bound-2] * 3 / 2 if upper_bound > 1 and upper_bound == set.length
result[upper_bound - 1] = result[upper_bound-1] * 3 if upper_bound == set.length
result[upper_bound - 2] = result[upper_bound-2] * 3 / 2 if upper_bound > 1 and upper_bound == set.length
result[0] = "null"
result
end # unsolved, not triggered, edge case for set.length == upper_bound + 1
def month_label(i)
I18n.t('date.month_names')[ (Time.zone.now.mon - i -1 ) % 12 + 1 ]
I18n.t('date.month_names')[(Time.zone.now.mon - i -1 ) % 12 + 1]
end
def array_of_month_labels(count)

View file

@ -1,8 +1,7 @@
module Stats
class Chart
attr_reader :action, :height, :width
def initialize(action, dimensions = {})
@action = action
@height = dimensions.fetch(:height) { 250 }
@ -12,7 +11,5 @@ module Stats
def dimensions
"#{width}x#{height}"
end
end
end

View file

@ -1,7 +1,7 @@
module Stats
class Contexts
attr_reader :user
def initialize(user)
@user = user
end

View file

@ -1,7 +1,7 @@
module Stats
class Projects
attr_reader :user
def initialize(user)
@user = user
end
@ -24,6 +24,5 @@ module Stats
projects = user.projects.order('created_at ASC')
projects.sort_by{ |p| p.running_time }.reverse.take(10)
end
end
end

View file

@ -2,8 +2,8 @@
# http://www.juixe.com/techknow/index.php/2006/07/15/acts-as-taggable-tag-cloud/
module Stats
class TagCloud
attr_reader :levels, :tags
def initialize(tags)
@levels = 10
@tags = tags.sort_by { |tag| tag.name.downcase }
@ -32,7 +32,7 @@ module Stats
end
def counts
@counts ||= tags.map {|t| t.count}
@counts ||= tags.map { |t| t.count }
end
end
end

View file

@ -1,7 +1,7 @@
module Stats
class TagCloudQuery
attr_reader :user, :cutoff
def initialize(user, cutoff = nil)
@user = user
@cutoff = cutoff
@ -19,20 +19,19 @@ module Stats
def sql
# 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 << " WHERE tags.id = tag_id"
query << " AND todos.user_id=? "
query << " AND taggings.taggable_type='Todo' "
query << " AND taggings.taggable_id=todos.id "
query << " AND todos.user_id = ? "
query << " AND taggings.taggable_type = 'Todo' "
query << " AND taggings.taggable_id = todos.id "
if cutoff
query << " AND (todos.created_at > ? OR "
query << " todos.completed_at > ?) "
end
query << " GROUP BY tags.id, tags.name"
query << " ORDER BY count DESC, name"
query << " ORDER BY count DESC, name "
query << " LIMIT 100"
end
end
end

View file

@ -1,9 +1,9 @@
module Stats
class TimeToComplete
SECONDS_PER_DAY = 86400;
SECONDS_PER_DAY = 86_400
attr_reader :actions
def initialize(actions)
@actions = actions
end
@ -52,12 +52,11 @@ module Stats
end
def sum
@sum ||= durations.inject(0) {|sum, d| sum + d}
@sum ||= durations.inject(0) { |sum, d| sum + d }
end
def arbitrary_day
@arbitrary_day ||= Time.utc(2000, 1, 1, 0, 0)
end
end
end

View file

@ -3,8 +3,8 @@
# and visible contexts will be included.
module Stats
class TopContextsQuery
attr_reader :user, :running, :limit
def initialize(user, options = {})
@user = user
@running = options.fetch(:running) { false }

View file

@ -3,8 +3,8 @@
# or completed since that cutoff will be included.
module Stats
class TopProjectsQuery
attr_reader :user, :cutoff
def initialize(user, cutoff = nil)
@user = user
@cutoff = cutoff
@ -34,6 +34,5 @@ module Stats
query << "ORDER BY count DESC "
query << "LIMIT 10"
end
end
end

View file

@ -1,7 +1,7 @@
module Stats
class Totals
attr_reader :user
def initialize(user)
@user = user
end
@ -83,6 +83,5 @@ module Stats
def tag_ids
@tag_ids ||= Stats::UserTagsQuery.new(user).result.map(&:id)
end
end
end

View file

@ -1,7 +1,7 @@
module Stats
class UserStats
attr_reader :user
def initialize(user)
@user = user
end
@ -38,6 +38,5 @@ module Stats
end
@tag_cloud_90days
end
end
end

View file

@ -1,7 +1,7 @@
module Stats
class UserTagsQuery
attr_reader :user
def initialize(user)
@user = user
end
@ -21,6 +21,5 @@ module Stats
AND todos.user_id = ?
SQL
end
end
end

View file

@ -1,5 +1,4 @@
class Tag < ApplicationRecord
has_many :taggings
has_many :taggable, :through => :taggings
@ -29,5 +28,4 @@ class Tag < ApplicationRecord
def to_s
name
end
end

View file

@ -1,8 +1,5 @@
# The Tagging join model.
class Tagging < ApplicationRecord
belongs_to :tag
belongs_to :taggable, :polymorphic => true, :touch => true
@ -13,5 +10,4 @@ class Tagging < ApplicationRecord
def delete_orphaned_tag
tag.destroy if tag and tag.taggings.count == 0
end
end

View file

@ -1,7 +1,6 @@
class Todo < ApplicationRecord
MAX_DESCRIPTION_LENGTH = 300
MAX_NOTES_LENGTH = 60000
MAX_NOTES_LENGTH = 60_000
after_save :save_predecessors
@ -19,9 +18,9 @@ class Todo < ApplicationRecord
has_many :successor_dependencies, :foreign_key => 'successor_id', :class_name => 'Dependency', :dependent => :destroy
has_many :predecessors, :through => :successor_dependencies
has_many :successors, :through => :predecessor_dependencies
has_many :uncompleted_predecessors, -> {where('NOT (todos.state = ?)', 'completed')}, :through => :successor_dependencies,
has_many :uncompleted_predecessors, -> { where('NOT (todos.state = ?)', 'completed') }, :through => :successor_dependencies,
:source => :predecessor
has_many :pending_successors, -> {where('todos.state = ?', 'pending')}, :through => :predecessor_dependencies,
has_many :pending_successors, -> { where('todos.state = ?', 'pending') }, :through => :predecessor_dependencies,
:source => :successor
has_many :attachments, dependent: :destroy
@ -32,14 +31,14 @@ class Todo < ApplicationRecord
scope :project_hidden, -> { joins('LEFT OUTER JOIN projects p ON p.id = todos.project_id').where('p.state = ?', 'hidden') }
scope :completed, -> { where 'todos.state = ?', 'completed' }
scope :deferred, -> { where 'todos.state = ?', 'deferred' }
scope :blocked, -> {where 'todos.state = ?', 'pending' }
scope :pending, -> {where 'todos.state = ?', 'pending' }
scope :blocked, -> { where 'todos.state = ?', 'pending' }
scope :pending, -> { where 'todos.state = ?', 'pending' }
scope :deferred_or_blocked, -> { where '(todos.state = ?) OR (todos.state = ?)', 'deferred', 'pending' }
scope :hidden, -> {
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').
where('(c_hidden.state = ? OR p_hidden.state = ?)', 'hidden', 'hidden').
where('NOT todos.state = ?', 'completed') }
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')
.where('(c_hidden.state = ? OR p_hidden.state = ?)', 'hidden', 'hidden')
.where('NOT todos.state = ?', 'completed') }
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_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 :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_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_before, lambda { |date| where("todos.completed_at < ?", date) }
scope :created_after, 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)
where('todos.due > ?', date)
@ -66,16 +65,15 @@ class Todo < ApplicationRecord
end
STARRED_TAG_NAME = "starred"
DEFAULT_INCLUDES = [ :project, :context, :tags, :taggings, :pending_successors, :uncompleted_predecessors, :recurring_todo ]
DEFAULT_INCLUDES = [:project, :context, :tags, :taggings, :pending_successors, :uncompleted_predecessors, :recurring_todo]
# state machine
include AASM
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
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 :pending
@ -124,7 +122,7 @@ class Todo < ApplicationRecord
end
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?)
end
@ -141,7 +139,7 @@ class Todo < ApplicationRecord
end
def not_part_of_hidden_container?
!( (self.project && self.project.hidden?) || self.context.hidden? )
!((self.project && self.project.hidden?) || self.context.hidden?)
end
# Returns a string with description <context, project>
@ -266,9 +264,9 @@ class Todo < ApplicationRecord
def add_predecessor_list(predecessor_list)
return unless predecessor_list.kind_of? String
@predecessor_array=predecessor_list.split(",").inject([]) do |list, todo_id|
predecessor = self.user.todos.find( todo_id.to_i ) if todo_id.present?
list << predecessor unless predecessor.nil?
@predecessor_array = predecessor_list.split(",").inject([]) do |list, todo_id|
predecessor = self.user.todos.find(todo_id.to_i) if todo_id.present?
list << predecessor unless predecessor.nil?
list
end
@ -284,15 +282,15 @@ class Todo < ApplicationRecord
# activate todos that should be activated if the current todo is completed
def activate_pending_todos
pending_todos = successors.select { |t| t.uncompleted_predecessors.empty? and !t.completed? }
pending_todos.each {|t| t.activate! }
pending_todos = successors.select { |t| t.uncompleted_predecessors.empty? && !t.completed? }
pending_todos.each { |t| t.activate! }
return pending_todos
end
# Return todos that should be blocked if the current todo is undone
def block_successors
active_successors = successors.select {|t| t.active? or t.deferred?}
active_successors.each {|t| t.block!}
active_successors = successors.select { |t| t.active? || t.deferred? }
active_successors.each { |t| t.block! }
return active_successors
end
@ -319,7 +317,7 @@ class Todo < ApplicationRecord
else
c = Context.where(:name => value[:name]).first
c = Context.create(value) if c.nil?
self.original_context=(c)
self.original_context = (c)
end
end
@ -331,13 +329,13 @@ class Todo < ApplicationRecord
alias_method :original_project=, :project=
def project=(value)
if value.is_a? Project
self.original_project=(value)
self.original_project = (value)
elsif !(value.nil? || value.is_a?(NullProject))
p = Project.where(:name => value[:name]).first
p = Project.create(value) if p.nil?
self.original_project=(p)
self.original_project = (p)
else
self.original_project=value
self.original_project = value
end
end
@ -387,5 +385,4 @@ class Todo < ApplicationRecord
super
end
end

View file

@ -1,6 +1,5 @@
module Todos
class Calendar
attr_reader :user, :included_tables
def initialize(user)
@ -48,11 +47,10 @@ module Todos
@end_of_the_month ||= today.end_of_month
end
private
private
def actions
user.todos.not_completed.includes(included_tables).reorder("due")
end
end
end

View file

@ -15,8 +15,8 @@ module Todos
end
not_done_todos = not_done_todos.
reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC")).
includes(Todo::DEFAULT_INCLUDES)
reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))
.includes(Todo::DEFAULT_INCLUDES)
not_done_todos = not_done_todos.limit(sanitize(params[:limit])) if params[:limit]

View file

@ -22,7 +22,7 @@ class User < ApplicationRecord
end
end
has_many(:projects, -> {order 'projects.position ASC'}, dependent: :delete_all) do
has_many(:projects, -> { order 'projects.position ASC' }, dependent: :delete_all) do
def find_by_params(params)
find(params['id'] || params['project_id'])
end
@ -46,7 +46,7 @@ class User < ApplicationRecord
projects = self.projects_in_state_by_position(project.state)
position = projects.index(project)
return nil if position == 0 && offset < 0
projects.at( position + offset)
projects.at(position + offset)
end
def cache_note_counts
project_note_counts = Note.group(:project_id).count
@ -64,9 +64,9 @@ class User < ApplicationRecord
todos_in_project = where(scope_conditions).includes(:todos)
todos_in_project = todos_in_project.sort_by { |x| [-x.todos.active.count, -x.id] }
todos_in_project.reject{ |p| p.todos.active.count > 0 }
sorted_project_ids = todos_in_project.map {|p| p.id}
sorted_project_ids = todos_in_project.map { |p| p.id }
all_project_ids = self.map {|p| p.id}
all_project_ids = self.map { |p| p.id }
other_project_ids = all_project_ids - sorted_project_ids
update_positions(sorted_project_ids + other_project_ids)
@ -82,12 +82,12 @@ class User < ApplicationRecord
end
has_many :recurring_todos,
-> {order 'recurring_todos.completed_at DESC, recurring_todos.created_at DESC'},
-> { order 'recurring_todos.completed_at DESC, recurring_todos.created_at DESC' },
dependent: :delete_all
has_many(:deferred_todos,
-> { where('state = ?', 'deferred').
order('show_from ASC, todos.created_at DESC')},
-> { where('state = ?', 'deferred')
.order('show_from ASC, todos.created_at DESC') },
:class_name => 'Todo') do
def find_and_activate_ready
where('show_from <= ?', Time.current).collect { |t| t.activate! }
@ -196,7 +196,7 @@ class User < ApplicationRecord
BCrypt::Password.create(s)
end
protected
protected
def crypt_password
return if password.blank?
@ -218,5 +218,4 @@ protected
taggings = Tagging.where(taggable_id: ids).pluck(:id)
Tagging.where(id: taggings).delete_all
end
end