decidim-cleaner 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/app/commands/decidim/cleaner/admin/update_organization_cleaner.rb +1 -1
- data/app/jobs/decidim/cleaner/clean_inactive_users_job.rb +5 -4
- 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/version.rb +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f54787d174b568ded865927e72ec935eda6e9133b7f0852bc9e00e7aa1a3d7ca
|
4
|
+
data.tar.gz: 948c3bf4816c2ce34ce80d3d57196a5712c8fb286343662bfec2bfd3b4e3729a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6eac33bbda665f50c8e2e0ac84e7b5c7ee143e6adce9c624a31e9cb89ab9d2c31cb57c92cad167ee84420bf176ccf236a6a055bc288556cdfcc76cda940dcf5
|
7
|
+
data.tar.gz: bac945ce0b0830278a2536242d0397e6bf8f78d448de866bf4ff23ebb047726c7c3d74cacd43e35b570ed469d39dcf189a6f025efc1dc36770c242d3bbd4a116
|
data/README.md
CHANGED
@@ -22,6 +22,11 @@ bundle exec rails decidim_cleaner:install:migrations
|
|
22
22
|
bundle exec rails db:migrate
|
23
23
|
```
|
24
24
|
|
25
|
+
### Sidekiq Scheduler
|
26
|
+
[Further documentation](https://github.com/sidekiq-scheduler/sidekiq-scheduler)
|
27
|
+
|
28
|
+
**Sidekiq scheduler uses a 6 columns format**
|
29
|
+
|
25
30
|
You can then add to your 'config/sidekiq.yml' file:
|
26
31
|
|
27
32
|
```yaml
|
@@ -36,6 +41,15 @@ You can then add to your 'config/sidekiq.yml' file:
|
|
36
41
|
queue: scheduled
|
37
42
|
```
|
38
43
|
|
44
|
+
### Cronjob
|
45
|
+
```
|
46
|
+
# Warns and deletes inactive users
|
47
|
+
0 9 * * * cd /home/user/decidim_application && RAILS_ENV=production bundle exec rake decidim_cleaner:clean_inactive_users
|
48
|
+
|
49
|
+
# Deletes old admin logs
|
50
|
+
0 9 * * * cd /home/user/decidim_application && RAILS_ENV=production bundle exec rake decidim_cleaner:clean_admin_logs
|
51
|
+
```
|
52
|
+
|
39
53
|
## Available tasks
|
40
54
|
|
41
55
|
- [ ] **Delete inactive users**
|
@@ -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 < Rectify::Command
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# organization - The Organization that will be updated.
|
@@ -10,17 +10,20 @@ module Decidim
|
|
10
10
|
next unless organization.delete_inactive_users?
|
11
11
|
|
12
12
|
send_warning(Decidim::User.where(organization: organization)
|
13
|
+
.not_deleted
|
14
|
+
.where.not(email: "")
|
13
15
|
.where("last_sign_in_at < ?", Time.zone.now - (organization.delete_inactive_users_email_after || 365).days)
|
14
16
|
.where("last_sign_in_at > ?", Time.zone.now - (organization.delete_inactive_users_email_after || 365).days - 1.day))
|
17
|
+
|
15
18
|
delete_user_and_send_email(Decidim::User.where(organization: organization)
|
19
|
+
.not_deleted
|
20
|
+
.where.not(email: "")
|
16
21
|
.where("last_sign_in_at < ?", Time.zone.now - (organization.delete_inactive_users_after || 390).days))
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
20
25
|
def send_warning(users)
|
21
26
|
users.find_each do |user|
|
22
|
-
next if user.deleted?
|
23
|
-
|
24
27
|
InactiveUsersMailer.warning_inactive(user).deliver_now
|
25
28
|
Rails.logger.info "Inactive warning sent to #{user.email}"
|
26
29
|
end
|
@@ -28,8 +31,6 @@ module Decidim
|
|
28
31
|
|
29
32
|
def delete_user_and_send_email(users)
|
30
33
|
users.find_each do |user|
|
31
|
-
next if user.deleted?
|
32
|
-
|
33
34
|
InactiveUsersMailer.warning_deletion(user).deliver_now
|
34
35
|
Rails.logger.info "Deletion warning sent to #{user.email}"
|
35
36
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class AddDeleteAdminLogsToOrganization < ActiveRecord::Migration[
|
3
|
+
class AddDeleteAdminLogsToOrganization < ActiveRecord::Migration[5.2]
|
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[
|
3
|
+
class AddDeleteInactiveUsersToOrganization < ActiveRecord::Migration[5.2]
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Quentinchampenois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: decidim-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.26.0
|
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.26.0
|
27
27
|
description: Clean outdated data in Decidim's database.
|
28
28
|
email:
|
29
29
|
- 26109239+Quentinchampenois@users.noreply.github.com
|