decidim-cleaner 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/commands/decidim/cleaner/admin/update_organization_cleaner.rb +1 -1
- data/app/jobs/decidim/cleaner/clean_admin_logs_job.rb +1 -1
- data/app/jobs/decidim/cleaner/clean_inactive_users_job.rb +2 -4
- data/app/mailers/decidim/cleaner/inactive_users_mailer.rb +2 -2
- data/db/migrate/20230106105014_add_delete_admin_logs_to_organization.rb +1 -1
- data/db/migrate/20230110150032_add_delete_inactive_users_to_organization.rb +1 -1
- data/lib/decidim/cleaner/test/factories.rb +1 -1
- data/lib/decidim/cleaner/version.rb +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1e9caaddab424c8f9e7f90ae9b768821eb59a2c4084920087b753d23113bb78
|
4
|
+
data.tar.gz: 357866aea4f46dbc6cce35b2a2824f2ace75f9488704ae982e1a9855132c1a87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b19b452a1070f8d826a5dd71989cad8eee27cfac1c90c58bced93c916e10553d5a5694c24728291d00f0c1017e049db0227cfc2168ac7e6f56b319c41342f0ee
|
7
|
+
data.tar.gz: 717d7ad9eed4605e7700bdf7e4175042c01812296f2bc1ff2ad3ab95cdc204e85cec95ac0a23eceb8db60bc86c93847aa71e90f3499db2771d696a26e3da48e1
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic for updating the current
|
7
7
|
# organization cleaner.
|
8
|
-
class UpdateOrganizationCleaner <
|
8
|
+
class UpdateOrganizationCleaner < Decidim::Command
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# organization - The Organization that will be updated.
|
@@ -9,7 +9,7 @@ module Decidim
|
|
9
9
|
Decidim::Organization.find_each do |organization|
|
10
10
|
next unless organization.delete_admin_logs?
|
11
11
|
|
12
|
-
Decidim::ActionLog.where(organization:
|
12
|
+
Decidim::ActionLog.where(organization:).where("created_at < ?", Time.zone.now - (organization.delete_admin_logs_after || 365).days).delete_all
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -9,12 +9,10 @@ module Decidim
|
|
9
9
|
Decidim::Organization.find_each do |organization|
|
10
10
|
next unless organization.delete_inactive_users?
|
11
11
|
|
12
|
-
send_warning(Decidim::User.where(organization:
|
12
|
+
send_warning(Decidim::User.where(organization:)
|
13
13
|
.where("last_sign_in_at < ?", Time.zone.now - (organization.delete_inactive_users_email_after || 365).days)
|
14
14
|
.where("last_sign_in_at > ?", Time.zone.now - (organization.delete_inactive_users_email_after || 365).days - 1.day))
|
15
|
-
delete_user_and_send_email(Decidim::User
|
16
|
-
.where(organization: organization)
|
17
|
-
.where("last_sign_in_at < ?", Time.zone.now - (organization.delete_inactive_users_after || 390).days))
|
15
|
+
delete_user_and_send_email(Decidim::User.where(organization:).where("last_sign_in_at < ?", Time.zone.now - (organization.delete_inactive_users_after || 390).days))
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
@@ -13,7 +13,7 @@ module Decidim
|
|
13
13
|
"decidim.cleaner.inactive_users_mailer.warning_inactive.subject",
|
14
14
|
organization_name: @organization.name
|
15
15
|
)
|
16
|
-
mail(to: user.email, subject:
|
16
|
+
mail(to: user.email, subject:)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -25,7 +25,7 @@ module Decidim
|
|
25
25
|
"decidim.cleaner.inactive_users_mailer.warning_deletion.subject",
|
26
26
|
organization_name: @organization.name
|
27
27
|
)
|
28
|
-
mail(to: user.email, subject:
|
28
|
+
mail(to: user.email, subject:)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class AddDeleteAdminLogsToOrganization < ActiveRecord::Migration[6.
|
3
|
+
class AddDeleteAdminLogsToOrganization < ActiveRecord::Migration[6.1]
|
4
4
|
def change
|
5
5
|
add_column :decidim_organizations, :delete_admin_logs, :boolean, default: false, null: false
|
6
6
|
add_column :decidim_organizations, :delete_admin_logs_after, :integer
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class AddDeleteInactiveUsersToOrganization < ActiveRecord::Migration[6.
|
3
|
+
class AddDeleteInactiveUsersToOrganization < ActiveRecord::Migration[6.1]
|
4
4
|
def change
|
5
5
|
add_column :decidim_organizations, :delete_inactive_users, :boolean, default: false, null: false
|
6
6
|
add_column :decidim_organizations, :delete_inactive_users_email_after, :integer
|
@@ -5,7 +5,7 @@ require "decidim/core/test/factories"
|
|
5
5
|
FactoryBot.define do
|
6
6
|
factory :cleaner_component, parent: :component do
|
7
7
|
name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :cleaner).i18n_name }
|
8
|
-
manifest_name
|
8
|
+
manifest_name :cleaner
|
9
9
|
participatory_space { create(:participatory_process, :with_steps) }
|
10
10
|
end
|
11
11
|
end
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Quentinchampenois
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-02-13 00:00:00.000000000 Z
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.28.0.dev
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.28.0.dev
|
27
27
|
description: Clean outdated data in Decidim's database.
|
28
28
|
email:
|
29
29
|
- 26109239+Quentinchampenois@users.noreply.github.com
|
@@ -76,7 +76,7 @@ metadata:
|
|
76
76
|
funding_uri: https://opencollective.com/decidim
|
77
77
|
homepage_uri: https://decidim.org
|
78
78
|
source_code_uri: https://github.com/decidim/decidim
|
79
|
-
post_install_message:
|
79
|
+
post_install_message:
|
80
80
|
rdoc_options: []
|
81
81
|
require_paths:
|
82
82
|
- lib
|
@@ -84,15 +84,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
84
|
requirements:
|
85
85
|
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
87
|
+
version: '3.1'
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
|
-
rubygems_version: 3.3.
|
95
|
-
signing_key:
|
94
|
+
rubygems_version: 3.3.5
|
95
|
+
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: A decidim cleaner module
|
98
98
|
test_files: []
|