Make MARC roles an enum and restructure how contributors are fetched from the DB to reduce queries

This commit is contained in:
Alex Cabal 2024-11-11 12:01:53 -06:00
parent daf8e16ef4
commit d6a2bdcbc8
8 changed files with 91 additions and 75 deletions

View file

@ -23,8 +23,10 @@ $types = ['epub', 'epub-advanced', 'azw3', 'kepub', 'xhtml'];
$groups = ['collections', 'subjects', 'authors', 'months'];
$ebooksByGroup = ['collections' => [], 'subjects' => [], 'authors' => [], 'months' => []];
/**
* @see https://www.php.net/manual/en/function.rmdir.php#117354
*/
function rrmdir(string $src): void{
// See <https://www.php.net/manual/en/function.rmdir.php#117354>.
$dir = opendir($src);
while(false !== ($file = readdir($dir))){
if (($file != '.') && ($file != '..')){
@ -94,8 +96,8 @@ function CreateZip(string $filePath, array $ebooks, string $type, string $webRoo
$zip->close();
// We have to do a copy, then unlink because rename() can't rename across file systems.
// If the bulk downloads are symlinked to a storage volume, the rename() won't work.
// We have to do a copy, then unlink because `rename()` can't rename across file systems.
// If the bulk downloads are symlinked to a storage volume, then `rename()` won't work.
copy($tempFilename, $filePath);
unlink($tempFilename);
@ -167,7 +169,7 @@ foreach(Ebook::GetAll() as $ebook){
}
// Add to the 'books by author' list.
// We have to index by UrlName for cases like `Samuel Butler` whose UrlName is `samuel-butler-1612-1680`.
// We have to index by `UrlName` for cases like `Samuel Butler` whose `UrlName` is `samuel-butler-1612-1680`.
$authorsUrl = preg_replace('|^/ebooks/|', '', $ebook->AuthorsUrl);
if(!isset($ebooksByGroup['authors'][$authorsUrl])){
$obj = new stdClass();