|
| 1 | +-- Execute these SQL commands to (re)configure and test WUPS |
| 2 | + |
| 3 | +-- configure |
| 4 | +update redcap_config set value="all" where field_name = "suspend_users_inactive_type"; |
| 5 | +update redcap_config set value="1" where field_name = "suspend_users_inactive_send_email"; |
| 6 | +update redcap_config set value="30" where field_name = "suspend_users_inactive_days"; |
| 7 | + |
| 8 | +update redcap_user_information set user_lastlogin = date_add(now(), interval -22 day), user_lastactivity = date_add(now(), interval -10 day) where username='alice'; |
| 9 | +update redcap_user_information set user_lastlogin = date_add(now(), interval -18 day), user_lastactivity = NULL where username='bob'; |
| 10 | +update redcap_user_information set user_lastlogin = date_add(now(), interval -10 day), user_lastactivity = date_add(now(), interval -25 day) where username='carol'; |
| 11 | +update redcap_user_information set user_lastlogin = null, user_lastactivity = date_add(now(), interval -20 day) where username='dan'; |
| 12 | + |
| 13 | +update redcap_user_information set user_email = 'pbc@ufl.edu' where username in ("admin","alice", "bob", "carol", "dan"); |
| 14 | + |
| 15 | +update redcap_crons set cron_frequency = 60, cron_max_run_time = 10 where cron_name = "warn_users_account_suspension_cron"; |
| 16 | + |
| 17 | +-- Adjust the cron frequency now! |
| 18 | +update redcap_crons set cron_frequency = 60 where cron_id > 34; |
| 19 | + |
| 20 | +-- reset everyone's last login and last activity dates |
| 21 | +update redcap_user_information set user_lastlogin = date_add(now(), interval -22 day), user_lastactivity = date_add(now(), interval -10 day) where username='alice'; |
| 22 | +update redcap_user_information set user_lastlogin = date_add(now(), interval -18 day), user_lastactivity = NULL where username='bob'; |
| 23 | +update redcap_user_information set user_lastlogin = date_add(now(), interval -10 day), user_lastactivity = date_add(now(), interval -25 day) where username='carol'; |
| 24 | +update redcap_user_information set user_lastlogin = null, user_lastactivity = date_add(now(), interval -20 day) where username='dan'; |
| 25 | + |
| 26 | +-- Verify the above query worked |
| 27 | +select * from ( |
| 28 | +select username, user_email, user_sponsor, user_firstname, user_lastname, user_lastactivity, user_lastlogin, |
| 29 | +(case |
| 30 | +when user_lastactivity is not null and user_lastlogin is not null then greatest(user_lastlogin, user_lastactivity) |
| 31 | +when user_lastactivity is not null then user_lastactivity |
| 32 | +when user_lastlogin is not null then user_lastlogin |
| 33 | +when user_creation is not null then user_creation |
| 34 | +end) as user_last_date |
| 35 | +from redcap_user_information |
| 36 | +where user_suspended_time is null |
| 37 | +) as my_user_info |
| 38 | +where 30 - DATEDIFF(NOW(), user_last_date) in (10,12,20); |
| 39 | + |
| 40 | +-- verify the module has a cron job |
| 41 | +SELECT * FROM `redcap_crons` |
| 42 | +WHERE cron_id > 34 |
| 43 | +order by cron_id desc; |
| 44 | + |
| 45 | +-- verify the module's config |
| 46 | +select * from redcap_external_module_settings |
| 47 | +where external_module_id in ( |
| 48 | +SELECT external_module_id FROM `redcap_external_modules` |
| 49 | +where directory_prefix = 'warn_users_of_pending_suspension'); |
| 50 | + |
| 51 | +-- verify the cron history |
| 52 | +SELECT * FROM `redcap_crons_history` as ch |
| 53 | +inner join redcap_crons as c on (ch.cron_id = c.cron_id) |
| 54 | +WHERE c.cron_name = 'warn_users_account_suspension_cron' |
| 55 | +order by ch_id desc; |
0 commit comments