mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Add a dirtiness check to slim down JSON LDAP sync summaries
This commit is contained in:
parent
338106734a
commit
fad0ed6d5b
|
@ -191,6 +191,7 @@ class LdapSync extends Command
|
||||||
];
|
];
|
||||||
// Only update the database if is not a dry run
|
// Only update the database if is not a dry run
|
||||||
if (!$this->dryrun) {
|
if (!$this->dryrun) {
|
||||||
|
if ($user->isDirty()) { //if nothing on the user changed, don't bother trying to save anything nor put anything in the summary
|
||||||
if ($user->save()) {
|
if ($user->save()) {
|
||||||
$summary['note'] = ($user->wasRecentlyCreated ? 'CREATED' : 'UPDATED');
|
$summary['note'] = ($user->wasRecentlyCreated ? 'CREATED' : 'UPDATED');
|
||||||
$summary['status'] = 'SUCCESS';
|
$summary['status'] = 'SUCCESS';
|
||||||
|
@ -202,11 +203,16 @@ class LdapSync extends Command
|
||||||
$summary['note'] = $snipeUser->getDN().' was not imported. REASON: '.$errors;
|
$summary['note'] = $snipeUser->getDN().' was not imported. REASON: '.$errors;
|
||||||
$summary['status'] = 'ERROR';
|
$summary['status'] = 'ERROR';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$summary = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// $summary['note'] = ($user->getOriginal('username') ? 'UPDATED' : 'CREATED'); // this seems, kinda, like, superfluous, relative to the $summary['note'] thing above, yeah?
|
// $summary['note'] = ($user->getOriginal('username') ? 'UPDATED' : 'CREATED'); // this seems, kinda, like, superfluous, relative to the $summary['note'] thing above, yeah?
|
||||||
|
if($summary) { //if the $user wasn't dirty, $summary was set to null so that we will skip the following push()
|
||||||
$this->summary->push($summary);
|
$this->summary->push($summary);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the users to update / create.
|
* Process the users to update / create.
|
||||||
|
|
Loading…
Reference in a new issue