mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 22:39:34 +00:00
no message
This commit is contained in:
1 parent
e1712c8fcd
commit
c77b19d229
8 files changed
+334
-30
No files matched your search
@@ -53,7 +53,7 @@ class SyncOffice365 extends Command
|
||||
return ! Project::where('code', $projectCode)->exists();
|
||||
});
|
||||
|
||||
$subtasks = array_filter($events, function ($event) {
|
||||
$subtasks_from_office365 = array_filter($events, function ($event) {
|
||||
$projectCode = explode(' ', $event['subject'])[0];
|
||||
|
||||
// if project code exist in database, then it is subtask
|
||||
@@ -66,7 +66,7 @@ class SyncOffice365 extends Command
|
||||
return ! Blocker::where('office365_id', $event['id'])->exists() && ! $event['isCancelled'];
|
||||
});
|
||||
|
||||
$newSubtasks = array_filter($subtasks, function ($event) {
|
||||
$newSubtasks = array_filter($subtasks_from_office365, function ($event) {
|
||||
return ! SubTask::where('office365_id', $event['id'])->exists() && ! $event['isCancelled'];
|
||||
});
|
||||
|
||||
@@ -81,7 +81,15 @@ class SyncOffice365 extends Command
|
||||
return $blocker && $blocker->office365_change_key !== $event['changeKey'];
|
||||
});
|
||||
|
||||
// get edited subtasks - the ones, that has different changeKey from our database
|
||||
$editedSubtasks = array_filter($subtasks_from_office365, function ($event) {
|
||||
$subtask = SubTask::where('office365_id', $event['id'])->first();
|
||||
|
||||
return $subtask && $subtask->office365_change_key !== $event['changeKey'];
|
||||
});
|
||||
|
||||
Office365Service::editBlockers($editedBlockers);
|
||||
Office365Service::editSubtasks($editedSubtasks);
|
||||
|
||||
// get all canceled blockers - the ones, that are in our database and in the response they have isCancelled => true
|
||||
$removedBlockers = Blocker::whereNotNull('office365_id')->get()->filter(function ($blocker) use (
|
||||
@@ -97,6 +105,34 @@ class SyncOffice365 extends Command
|
||||
$blocker->delete();
|
||||
});
|
||||
|
||||
// get all canceled subtasks - the ones, that are in our database and in the response they have isCancelled => true
|
||||
|
||||
$removedSubtasks = SubTask::where('is_finished', 0)->whereNotNull('office365_id')->get()->filter(function (
|
||||
$subtask
|
||||
) use (
|
||||
$subtasks_from_office365
|
||||
) {
|
||||
$event = collect($subtasks_from_office365)->firstWhere('id', $subtask->office365_id);
|
||||
|
||||
return $event && $event['isCancelled'];
|
||||
});
|
||||
|
||||
//dd($removedSubtasks);
|
||||
|
||||
foreach ($removedSubtasks as $subtaskToDelete) {
|
||||
// vymazanie timeblockov
|
||||
foreach ($subtaskToDelete->timeblocks as $timeblock) {
|
||||
$timeblock->delete();
|
||||
}
|
||||
|
||||
// vymazanie timesheetov
|
||||
foreach ($subtaskToDelete->timesheets as $timesheet) {
|
||||
$timesheet->delete();
|
||||
}
|
||||
|
||||
$subtaskToDelete->delete();
|
||||
}
|
||||
|
||||
dd('he');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user