$unitOfWork->getEntityChangeSet($entity);
$metaData = $entityManager->getClassMetadata(get_class($entity));
//отбираем ассоциации "не коллекции" и только изменненные.
$singleAssociations = array_filter($metaData->getAssociationNames(), function ($association) use ($metaData) {
return $metaData->isSingleValuedAssociation($association);
});
$data = [];
foreach ($changesSet as $key => $field) {
if (in_array($key, $singleAssociations)) {
// где $field[0] и $field[1] будут как раз простыми ассоциациями "до" и "после"
//getAssocFieldValue - просто метод который берет из ассоциации нужное простое значение для лога
$data[$key] = [$this->getAssocFieldValue($field[0]), $this->getAssocFieldValue($field[1])];
}
}
console.log(
foundMovies.map((i) =>
nominates.some( (z) => z.id === i.id && z.title === i.title && z.year === i.year ) ? { ...i, ...{ status: true } } : i ));
let colors = ["red", "pink", "coral", "orange", "yellow", "green"];
let t = setInterval(function () {
if (!colors.length) clearTimeout(t);
colors.length && console.log(colors.shift());
}, 1000);
var getDatesBetweenDates = (startDate, endDate) => {
let dates = []
const theDate = new Date(startDate)
while (theDate < endDate) {
dates = [...dates, new Date(theDate)]
theDate.setDate(theDate.getDate() + 1)
}
return dates
}
(getDatesBetweenDates(new Date(2020,11,1), new Date(2020,11,7))).map((i)=>i.toLocaleString('ru',
{
day: '2-digit',
year: '2-digit',
month: '2-digit',}))
сreate table tickets(id INT NULL,film_name VARCHAR(100) NULL, start_time DATETIME ,dur INT NULL );
INSERT INTO tickets (id, film_name, start_time, dur)
VALUES
(1, 'f1', '2020-10-10 12:00:00', 60),
(2, 'f2', '2020-10-10 11:30:00', 20),
(3, 'f3', '2020-10-10 10:50:00', 90),
(4, 'f4', '2020-10-10 11:10:00', 60),
(5, 'f5', '2020-10-10 10:50:00', 120);
#-------------САМО РЕШЕНИЕ-------------------
SET @film_id := 1; # здесь у нас ID фильма по которому проверяем интервалы
SET @startRange = (SELECT start_time FROM tickets WHERE id= @film_id) ;
SET @endRange = (SELECT start_time + INTERVAL dur MINUTE FROM tickets WHERE id= @film_id);
select * from
(select * , start_time + INTERVAL dur MINUTE as end_time from tickets)
as table_with_end_time
WHERE
(table_with_end_time.start_time >= @startRange AND table_with_end_time.start_time <= @endRange)
OR(table_with_end_time.end_time >= @startRange AND table_with_end_time.end_time <= @endRange )
OR(table_with_end_time.start_time <= @startRange AND table_with_end_time.end_time >= @endRange)
let resultsReturned = false;
let finishJobs = function (tasksQueue) {
tasksQueue.getJobCounts().then((count) => {
if (!count.waiting && !count.active) {
if (!resultsReturned) {
resultsReturned = true;
results.forEach(i => console.table(i));
setTimeout(() => {
resultsReturned = false;
results = [];
}, 500);
}
}
});
};
tasksQueue.on('completed', function (job, result) {
results.push(result);
job.remove();
finishJobs(tasksQueue);
}
);