days: fix reverse on preloads (fix #895)
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/900/head
parent
a305ddc4ad
commit
a8d940acd0
|
@ -42,17 +42,13 @@ class DaysController extends GenericApiController
|
||||||
$this->isRecursive(),
|
$this->isRecursive(),
|
||||||
$this->isArchive(),
|
$this->isArchive(),
|
||||||
$this->isMonthView(),
|
$this->isMonthView(),
|
||||||
|
$this->isReverse(),
|
||||||
$this->getTransformations(),
|
$this->getTransformations(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Preload some day responses
|
// Preload some day responses
|
||||||
$this->preloadDays($list);
|
$this->preloadDays($list);
|
||||||
|
|
||||||
// Reverse response if requested.
|
|
||||||
if ($this->isReverse()) {
|
|
||||||
$list = array_reverse($list);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new JSONResponse($list, Http::STATUS_OK);
|
return new JSONResponse($list, Http::STATUS_OK);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -74,14 +70,10 @@ class DaysController extends GenericApiController
|
||||||
$this->isArchive(),
|
$this->isArchive(),
|
||||||
$this->isHidden(),
|
$this->isHidden(),
|
||||||
$this->isMonthView(),
|
$this->isMonthView(),
|
||||||
|
$this->isReverse(),
|
||||||
$this->getTransformations(),
|
$this->getTransformations(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Reverse response if requested.
|
|
||||||
if ($this->isReverse()) {
|
|
||||||
$list = array_reverse($list);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new JSONResponse($list, Http::STATUS_OK);
|
return new JSONResponse($list, Http::STATUS_OK);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -181,6 +173,7 @@ class DaysController extends GenericApiController
|
||||||
$this->isArchive(),
|
$this->isArchive(),
|
||||||
$this->isHidden(),
|
$this->isHidden(),
|
||||||
$this->isMonthView(),
|
$this->isMonthView(),
|
||||||
|
$this->isReverse(),
|
||||||
$this->getTransformations(),
|
$this->getTransformations(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ trait TimelineQueryDays
|
||||||
* @param bool $recursive Whether to get the days recursively
|
* @param bool $recursive Whether to get the days recursively
|
||||||
* @param bool $archive Whether to get the days only from the archive folder
|
* @param bool $archive Whether to get the days only from the archive folder
|
||||||
* @param bool $monthView Whether the response should be in month view
|
* @param bool $monthView Whether the response should be in month view
|
||||||
|
* @param bool $reverse Whether the response should be in reverse order
|
||||||
* @param array $queryTransforms An array of query transforms to apply to the query
|
* @param array $queryTransforms An array of query transforms to apply to the query
|
||||||
*
|
*
|
||||||
* @return array The days response
|
* @return array The days response
|
||||||
|
@ -29,6 +30,7 @@ trait TimelineQueryDays
|
||||||
bool $recursive,
|
bool $recursive,
|
||||||
bool $archive,
|
bool $archive,
|
||||||
bool $monthView,
|
bool $monthView,
|
||||||
|
bool $reverse,
|
||||||
array $queryTransforms = [],
|
array $queryTransforms = [],
|
||||||
): array {
|
): array {
|
||||||
$query = $this->connection->getQueryBuilder();
|
$query = $this->connection->getQueryBuilder();
|
||||||
|
@ -54,7 +56,14 @@ trait TimelineQueryDays
|
||||||
$rows = $this->executeQueryWithCTEs($query)->fetchAll();
|
$rows = $this->executeQueryWithCTEs($query)->fetchAll();
|
||||||
|
|
||||||
// Post process the days
|
// Post process the days
|
||||||
return $this->postProcessDays($rows, $monthView);
|
$rows = $this->postProcessDays($rows, $monthView);
|
||||||
|
|
||||||
|
// Reverse order if needed
|
||||||
|
if ($reverse) {
|
||||||
|
$rows = array_reverse($rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +74,7 @@ trait TimelineQueryDays
|
||||||
* @param bool $archive If the query should include only the archive folder
|
* @param bool $archive If the query should include only the archive folder
|
||||||
* @param bool $hidden If the query should include hidden files
|
* @param bool $hidden If the query should include hidden files
|
||||||
* @param bool $monthView If the query should be in month view (dayIds are monthIds)
|
* @param bool $monthView If the query should be in month view (dayIds are monthIds)
|
||||||
|
* @param bool $reverse If the query should be in reverse order
|
||||||
* @param array $queryTransforms The query transformations to apply
|
* @param array $queryTransforms The query transformations to apply
|
||||||
*
|
*
|
||||||
* @return array An array of day responses
|
* @return array An array of day responses
|
||||||
|
@ -75,6 +85,7 @@ trait TimelineQueryDays
|
||||||
bool $archive,
|
bool $archive,
|
||||||
bool $hidden,
|
bool $hidden,
|
||||||
bool $monthView,
|
bool $monthView,
|
||||||
|
bool $reverse,
|
||||||
array $queryTransforms = [],
|
array $queryTransforms = [],
|
||||||
): array {
|
): array {
|
||||||
// Check if we have any dayIds
|
// Check if we have any dayIds
|
||||||
|
@ -135,6 +146,11 @@ trait TimelineQueryDays
|
||||||
$this->postProcessDayPhoto($photo, $monthView);
|
$this->postProcessDayPhoto($photo, $monthView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reverse order if needed
|
||||||
|
if ($reverse) {
|
||||||
|
$day = array_reverse($day);
|
||||||
|
}
|
||||||
|
|
||||||
return $day;
|
return $day;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue