Skip to content

Commit

Permalink
removed rubocop changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
ElviaBth committed Jun 10, 2024
1 parent 03c1003 commit 9e519f8
Show file tree
Hide file tree
Showing 39 changed files with 82 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def query
.where(component: visible_components_from_spaces(spaces))
.joins(:component)
.left_outer_joins(:category)
@query = @query.where(decidim_accountability_results: { created_at: ..end_time })
@query = @query.where("decidim_accountability_results.created_at <= ?", end_time)
@query = @query.group("decidim_categorizations.decidim_category_id",
:participatory_space_type,
:participatory_space_id,
Expand All @@ -48,7 +48,7 @@ def query
end

def quantity
@quantity ||= query.where(decidim_accountability_results: { created_at: start_time.. }).count
@quantity ||= query.where("decidim_accountability_results.created_at >= ?", start_time).count
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def query
return @query if @query

@query = Decidim::Assembly.where(organization: @organization)
@query = @query.where(decidim_assemblies: { published_at: ..end_time })
@query = @query.where("decidim_assemblies.published_at <= ?", end_time)
@query
end

def quantity
@quantity ||= query.where(decidim_assemblies: { published_at: start_time.. }).count
@quantity ||= query.where("decidim_assemblies.published_at >= ?", start_time).count
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-blogs/app/models/decidim/blogs/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Post < Blogs::ApplicationRecord
validates :title, presence: true

scope :created_at_desc, -> { order(arel_table[:created_at].desc) }
scope :published, -> { where(published_at: ..Time.current) }
scope :published, -> { where("published_at <= ?", Time.current) }

searchable_fields({
participatory_space: { component: :participatory_space },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def initialize(components, start_at = nil, end_at = nil)
# by a range of dates.
def query
projects = Decidim::Budgets::Project.where(budget: budgets)
projects = projects.where(created_at: @start_at..) if @start_at.present?
projects = projects.where(created_at: ..@end_at) if @end_at.present?
projects = projects.where("created_at >= ?", @start_at) if @start_at.present?
projects = projects.where("created_at <= ?", @end_at) if @end_at.present?
projects
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def calculate
projects = Decidim::Budgets::Project.where(budget: budgets)

budgets_followers = Decidim::Follow.where(followable: projects).joins(:user)
.where(decidim_follows: { created_at: ..end_time })
.where("decidim_follows.created_at <= ?", end_time)
cumulative_users = budgets_followers.pluck(:decidim_user_id)

budgets_followers = budgets_followers.where(decidim_follows: { created_at: start_time.. })
budgets_followers = budgets_followers.where("decidim_follows.created_at >= ?", start_time)
quantity_users = budgets_followers.pluck(:decidim_user_id)

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def calculate
budgets = Decidim::Budgets::Budget.where(component: @resource)
orders = Decidim::Budgets::Order.where(budget: budgets)
.finished
.where(decidim_budgets_orders: { checked_out_at: ..end_time })
.where("decidim_budgets_orders.checked_out_at <= ?", end_time)

{
cumulative_users: orders.pluck(:decidim_user_id),
quantity_users: orders.where(decidim_budgets_orders: { checked_out_at: start_time.. }).pluck(:decidim_user_id)
quantity_users: orders.where("decidim_budgets_orders.checked_out_at >= ?", start_time).pluck(:decidim_user_id)
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions decidim-budgets/lib/decidim/budgets/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
component.register_stat :orders_count do |components, start_at, end_at|
budgets = Decidim::Budgets::Budget.where(component: components)
orders = Decidim::Budgets::Order.where(budget: budgets)
orders = orders.where(created_at: start_at..) if start_at.present?
orders = orders.where(created_at: ..end_at) if end_at.present?
orders = orders.where("created_at >= ?", start_at) if start_at.present?
orders = orders.where("created_at <= ?", end_at) if end_at.present?
orders.count
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def check_participatory_space(participatory_space, related_object)
def retrieve_comments_for_organization
user_ids = Decidim::User.where(organization: @resource.organization).pluck(:id)
Decidim::Comments::Comment.includes(:root_commentable).not_hidden.not_deleted
.where(decidim_comments_comments: { created_at: ..end_time })
.where("decidim_comments_comments.created_at <= ?", end_time)
.where(decidim_comments_comments: { decidim_author_id: user_ids })
.where(decidim_comments_comments: { decidim_author_type: "Decidim::UserBaseEntity" })
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def retrieve_comments
user_ids = Decidim::User.select(:id).where(organization: @organization).collect(&:id)
user_group_ids = Decidim::UserGroup.select(:id).where(organization: @organization).collect(&:id)
Decidim::Comments::Comment.includes(:root_commentable).not_hidden.not_deleted
.where(decidim_comments_comments: { created_at: ..end_time })
.where("decidim_comments_comments.created_at <= ?", end_time)
.where("decidim_comments_comments.decidim_author_id IN (?) OR
decidim_comments_comments.decidim_user_group_id IN (?)", user_ids, user_group_ids)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def query
return @query if @query

@query = Decidim::User.blocked.where(organization: @organization)
@query = @query.where(blocked_at: ..end_time)
@query = @query.where("blocked_at <= ?", end_time)
@query
end

def quantity
@quantity ||= @query.where(blocked_at: start_time..).count
@quantity ||= @query.where("blocked_at >= ?", start_time).count
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def query
.where("deleted_at IS NULL OR deleted_at > ?", end_time)
.where("blocked_at IS NULL OR blocked_at > ?", end_time)
.confirmed
.where(created_at: ..end_time)
.where("created_at <= ?", end_time)
end

def quantity
@quantity ||= query.where(created_at: start_time..).count
@quantity ||= query.where("created_at >= ?", start_time).count
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions decidim-core/app/queries/decidim/stats_users_count.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def initialize(organization, start_at = nil, end_at = nil)

def query
users = Decidim::User.where(organization: @organization).not_deleted.not_blocked.confirmed
users = users.where(created_at: @start_at..) if @start_at.present?
users = users.where(created_at: ..@end_at) if @end_at.present?
users = users.where("created_at >= ?", @start_at) if @start_at.present?
users = users.where("created_at <= ?", @end_at) if @end_at.present?
users.count
end
end
Expand Down
4 changes: 2 additions & 2 deletions decidim-core/lib/decidim/core/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ class Engine < ::Rails::Engine
Decidim.stats.register :processes_count, priority: StatsRegistry::HIGH_PRIORITY do |organization, start_at, end_at|
processes = ParticipatoryProcesses::OrganizationPrioritizedParticipatoryProcesses.new(organization)

processes = processes.where(created_at: start_at..) if start_at.present?
processes = processes.where(created_at: ..end_at) if end_at.present?
processes = processes.where("created_at >= ?", start_at) if start_at.present?
processes = processes.where("created_at <= ?", end_at) if end_at.present?
processes.count
end
end
Expand Down
6 changes: 4 additions & 2 deletions decidim-core/lib/tasks/decidim_download_your_data_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace :decidim do
input = $stdin.gets.chomp
if input.casecmp("y").zero?
puts %( Continue...)
Decidim::User.where(newsletter_notifications_at: ...Time.zone.parse("2018-05-25 00:00 +02:00")).find_each(&:newsletter_opt_in_notify)
Decidim::User.where("newsletter_notifications_at < ?", Time.zone.parse("2018-05-25 00:00 +02:00")).find_each(&:newsletter_opt_in_notify)
else
puts %( Execution cancelled...)
end
Expand All @@ -76,7 +76,9 @@ namespace :decidim do
attachments = ActiveStorage::Attachment.joins(:blob).where(
name: "download_your_data_file",
record_type: "Decidim::UserBaseEntity"
).where(active_storage_blobs: { created_at: ...Decidim.download_your_data_expiry_time.ago })
).where(
"active_storage_blobs.created_at < ?", Decidim.download_your_data_expiry_time.ago
)
attachments.each do |attachment|
delete_download_your_data_file attachment
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def calculate
debates = Decidim::Debates::Debate.where(component: @resource).joins(:component)

debates_followers = Decidim::Follow.where(followable: debates).joins(:user)
.where(decidim_follows: { created_at: ..end_time })
.where("decidim_follows.created_at <= ?", end_time)
cumulative_users = debates_followers.pluck(:decidim_user_id)

debates_followers = debates_followers.where(decidim_follows: { created_at: start_time.. })
debates_followers = debates_followers.where("decidim_follows.created_at >= ?", start_time)
quantity_users = debates_followers.pluck(:decidim_user_id)

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def valid?

def calculate
debates = Decidim::Debates::Debate.where(component: @resource).joins(:component)
.where(decidim_debates_debates: { created_at: ..end_time })
.where("decidim_debates_debates.created_at <= ?", end_time)
.where(decidim_author_type: Decidim::UserBaseEntity.name)
.where.not(author: nil)

{
cumulative_users: debates.pluck(:decidim_author_id),
quantity_users: debates.where(decidim_debates_debates: { created_at: start_time.. }).pluck(:decidim_author_id)
quantity_users: debates.where("decidim_debates_debates.created_at >= ?", start_time).pluck(:decidim_author_id)
}
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ def query

@query = Decidim::Debates::Debate.where(component: visible_components_from_spaces(retrieve_participatory_spaces)).joins(:component)
.left_outer_joins(:category)
@query = @query.where(decidim_debates_debates: { start_time: ..end_time })
@query = @query.where("decidim_debates_debates.start_time <= ?", end_time)
@query = @query.group("decidim_categorizations.decidim_category_id",
:participatory_space_type,
:participatory_space_id)
@query
end

def quantity
@quantity ||= query.where(decidim_debates_debates: { start_time: start_time.. }).count
@quantity ||= query.where("decidim_debates_debates.start_time >= ?", start_time).count
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions decidim-initiatives/app/models/decidim/initiative.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ class Initiative < ApplicationRecord
scope_search_multi :with_any_state, [:accepted, :rejected, :answered, :open, :closed]

scope :currently_signable, lambda {
where(signature_start_date: ..Date.current)
.where(signature_end_date: Date.current..)
where("signature_start_date <= ?", Date.current)
.where("signature_end_date >= ?", Date.current)
}
scope :currently_unsignable, lambda {
where("signature_start_date > ?", Date.current)
.or(where(signature_end_date: ...Date.current))
.or(where("signature_end_date < ?", Date.current))
}

scope :answered, -> { where.not(answered_at: nil) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def initialize(period_length)
def query
Decidim::Initiative
.where(state: "validating")
.where(updated_at: ...@period_length)
.where("updated_at < ?", @period_length)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def query
.includes(:scoped_type)
.where(state: "published")
.where(signature_type: "online")
.where(signature_end_date: ...Date.current)
.where("signature_end_date < ?", Date.current)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def initialize(components, start_at = nil, end_at = nil)
# by a range of dates.
def query
meetings = Decidim::Meetings::Meeting.not_hidden.published.where(component: @components)
meetings = meetings.where(created_at: @start_at..) if @start_at.present?
meetings = meetings.where(created_at: ..@end_at) if @end_at.present?
meetings = meetings.where("created_at >= ?", @start_at) if @start_at.present?
meetings = meetings.where("created_at <= ?", @end_at) if @end_at.present?
meetings
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def calculate
meetings = Decidim::Meetings::Meeting.where(component: @resource).joins(:component)

meetings_followers = Decidim::Follow.where(followable: meetings).joins(:user)
.where(decidim_follows: { created_at: ..end_time })
.where("decidim_follows.created_at <= ?", end_time)
cumulative_users = meetings_followers.pluck(:decidim_user_id)

meetings_followers = meetings_followers.where(decidim_follows: { created_at: start_time.. })
meetings_followers = meetings_followers.where("decidim_follows.created_at >= ?", start_time)
quantity_users = meetings_followers.pluck(:decidim_user_id)

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def query
end
@query = Decidim::Meetings::Meeting.where(component: visible_components_from_spaces(spaces)).joins(:component)
.left_outer_joins(:category).visible
@query = @query.where(decidim_meetings_meetings: { created_at: ..end_time })
@query = @query.where("decidim_meetings_meetings.created_at <= ?", end_time)
@query = @query.group("decidim_categorizations.decidim_category_id",
:participatory_space_type,
:participatory_space_id)
@query
end

def quantity
@quantity ||= query.where(decidim_meetings_meetings: { created_at: start_time.. }).count
@quantity ||= query.where("decidim_meetings_meetings.created_at >= ?", start_time).count
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions decidim-pages/lib/decidim/pages/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

component.register_stat :pages_count do |components, start_at, end_at|
pages = Decidim::Pages::Page.where(component: components)
pages = pages.where(created_at: start_at..) if start_at.present?
pages = pages.where(created_at: ..end_at) if end_at.present?
pages = pages.where("created_at >= ?", start_at) if start_at.present?
pages = pages.where("created_at <= ?", end_at) if end_at.present?
pages.count
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def perform
active_step = process.steps.find_by(active: true)
if steps.empty? && active_step
next_position = active_step.position + 1
next_step = process.steps.where(start_date: ..Time.zone.now.to_date).find_by(position: next_position)
next_step = process.steps.where("start_date <= ?", Time.zone.now.to_date).find_by(position: next_position)
if next_step.present?
active_step.update(active: false)
next_step.update(active: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def calculate
participatory_process = @resource

process_followers = Decidim::Follow.where(followable: participatory_process).joins(:user)
.where(decidim_follows: { created_at: ..end_time })
.where("decidim_follows.created_at <= ?", end_time)
cumulative_users = process_followers.pluck(:decidim_user_id)

process_followers = process_followers.where(decidim_follows: { created_at: start_time.. })
process_followers = process_followers.where("decidim_follows.created_at >= ?", start_time)
quantity_users = process_followers.pluck(:decidim_user_id)

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def query
return @query if @query

@query = Decidim::ParticipatoryProcess.where(organization: @organization)
@query = @query.where(decidim_participatory_processes: { published_at: ..end_time })
@query = @query.where("decidim_participatory_processes.published_at <= ?", end_time)
@query
end

def quantity
@quantity ||= query.where(decidim_participatory_processes: { published_at: start_time.. }).count
@quantity ||= query.where("decidim_participatory_processes.published_at >= ?", start_time).count
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def initialize(components, start_at = nil, end_at = nil)
# by a range of dates.
def query
proposals = Decidim::Proposals::Proposal.where(component: @components)
proposals = proposals.where(created_at: @start_at..) if @start_at.present?
proposals = proposals.where(created_at: ..@end_at) if @end_at.present?
proposals = proposals.where("created_at >= ?", @start_at) if @start_at.present?
proposals = proposals.where("created_at <= ?", @end_at) if @end_at.present?
proposals
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def query
end
@query = Decidim::Proposals::Proposal.where(component: visible_components_from_spaces(spaces)).joins(:component)
.left_outer_joins(:category)
@query = @query.where(decidim_proposals_proposals: { created_at: ..end_time }).accepted
@query = @query.where("decidim_proposals_proposals.created_at <= ?", end_time).accepted
@query = @query.group("decidim_categorizations.id", :participatory_space_type, :participatory_space_id)
@query
end

def quantity
@quantity ||= query.where(decidim_proposals_proposals: { created_at: start_time.. }).count
@quantity ||= query.where("decidim_proposals_proposals.created_at >= ?", start_time).count
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def query
.joins(join_categories)
.where(resource_id: proposals.pluck(:id))
.where(resource_type: Decidim::Proposals::Proposal.name)
@query = @query.where(decidim_endorsements: { created_at: ..end_time })
@query = @query.where("decidim_endorsements.created_at <= ?", end_time)
@query = @query.group("decidim_categorizations.id",
:participatory_space_type,
:participatory_space_id,
Expand All @@ -50,7 +50,7 @@ def query
end

def quantity
@quantity ||= query.where(decidim_endorsements: { created_at: start_time.. }).count
@quantity ||= query.where("decidim_endorsements.created_at >= ?", start_time).count
end
end
end
Expand Down
Loading

0 comments on commit 9e519f8

Please sign in to comment.