OpenSourcePolitics / decidim-module-cleaner

GNU Affero General Public License v3.0
4 stars 2 forks source link

Decidim::Cleaner

Clean outdated data in Decidim's database.

Usage

This module provides tasks designed to cleanup the outdated data directly in database.

Installation

Add this line to your application's Gemfile:

gem "decidim-cleaner"

And then execute:

bundle
bundle exec rails decidim_cleaner:install:migrations
bundle exec rails db:migrate

You can then modify the default values of the cleaner in your .ENV with the following variables:

# Delay until a user is considered inactive and receive a warning email (in days)
DECIDIM_CLEANER_INACTIVE_USERS_MAIL=

# Delay until a user is deleted after receiving an email (in days)
DECIDIM_CLEANER_DELETE_INACTIVE_USERS=

# Delay until an admin log is deleted (in days)
DECIDIM_CLEANER_DELETE_ADMIN_LOGS=

Sidekiq Scheduler

Further documentation

Sidekiq scheduler uses a 6 columns format

You can then add to your 'config/sidekiq.yml' file:

:schedule:
  CleanAdminLogs:
    cron: "0 9 0 * * *"
    class: Decidim::Cleaner::CleanAdminLogsJob
    queue: scheduled
  CleanInactiveUsers:
    cron: "0 9 0 * * *"
    class: Decidim::Cleaner::CleanInactiveUsersJob
    queue: scheduled

Cronjob

# Warns and deletes inactive users
0 9 * * * cd /home/user/decidim_application && RAILS_ENV=production bundle exec rake decidim_cleaner:clean_inactive_users

# Deletes old admin logs
0 9 * * * cd /home/user/decidim_application && RAILS_ENV=production bundle exec rake decidim_cleaner:clean_admin_logs

Available tasks

Contributing

Contributions are welcome !

We expect the contributions to follow the Decidim's contribution guide.

Security

Security is very important to us. If you have any issue regarding security, please disclose the information responsibly by sending an email to security [at] opensourcepolitics [dot] eu and not by creating a Github issue.

License

This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.