Skip to content

Commit

Permalink
fix: check of idir_user_guid and ignore if not available
Browse files Browse the repository at this point in the history
  • Loading branch information
NithinKuruba committed Jul 20, 2023
1 parent b1b0e0d commit 9d1a540
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions docker/kc-cron-job/remove-inactive-idir-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,9 @@ async function removeStaleUsersByEnv(env = 'dev', pgClient, runnerName, startFro

for (let x = 0; x < users.length; x++) {
const { id, username } = users[x];
const idir_user_guid = String(users[x].attributes.idir_user_guid).toLowerCase();
const displayName = String(users[x].attributes.display_name).toLowerCase();
const idir_user_guid = String(users[x]?.attributes?.idir_user_guid || '').toLowerCase();
if (!idir_user_guid) continue;
const displayName = String(users[x]?.attributes?.display_name || '').toLowerCase();
// ignore the users with `hold` in their displayname
if (displayName && displayName.startsWith('hold -')) continue;
log(`[${runnerName}] processing user ${username}`);
Expand Down Expand Up @@ -435,24 +436,24 @@ function main() {
function (cb) {
removeStaleUsersByEnv('dev', getPgClient(), 'dev', 0, cb);
},
function (cb) {
removeStaleUsersByEnv('test', getPgClient(), 'test', 0, cb);
},
function (cb) {
removeStaleUsersByEnv('prod', getPgClient(), 'prod-01', 0, cb);
},
function (cb) {
removeStaleUsersByEnv('prod', getPgClient(), 'prod-02', 10000, cb);
},
function (cb) {
removeStaleUsersByEnv('prod', getPgClient(), 'prod-03', 20000, cb);
},
function (cb) {
removeStaleUsersByEnv('prod', getPgClient(), 'prod-04', 30000, cb);
},
function (cb) {
removeStaleUsersByEnv('prod', getPgClient(), 'prod-05', 40000, cb);
},
// function (cb) {
// removeStaleUsersByEnv('test', getPgClient(), 'test', 0, cb);
// },
// function (cb) {
// removeStaleUsersByEnv('prod', getPgClient(), 'prod-01', 0, cb);
// },
// function (cb) {
// removeStaleUsersByEnv('prod', getPgClient(), 'prod-02', 10000, cb);
// },
// function (cb) {
// removeStaleUsersByEnv('prod', getPgClient(), 'prod-03', 20000, cb);
// },
// function (cb) {
// removeStaleUsersByEnv('prod', getPgClient(), 'prod-04', 30000, cb);
// },
// function (cb) {
// removeStaleUsersByEnv('prod', getPgClient(), 'prod-05', 40000, cb);
// },
],
async function (err, results) {
if (err) {
Expand Down

0 comments on commit 9d1a540

Please sign in to comment.