diff --git a/README.md b/README.md index 81b545b..9c584b5 100644 --- a/README.md +++ b/README.md @@ -59,5 +59,10 @@ This command consists of multiple subcommands that can be called separately: 4. Download images of models from rebrickable.com `$ bin/console app:load:images [--color=INT] [--rebrickable] [--missing]` 5. Populate Elastisearch index `$ bin/console fos:elastica:populate` +##### Adding part relation +Relations between LDraw models and Rebrickable parts are matched automatically by identical (or similar) id/name when executing command `$ bin/console app:load:relation`. + +Unmatched relations can be specified by adding relation of IDs to `app/Resources/relations/part_model.yml` + ## Testing You can run complete system tests by `$ phpunit`. These should cover the main system functions and the functionality of calling the third-party programs that are required are needed to seamlessly retrieve the necessary application data. diff --git a/app/config/config.yml b/app/config/config.yml index 83082ed..90d159c 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -12,7 +12,7 @@ parameters: name: "PrintABrick" # rebrickable csv files root URL (http://rebrickable.com/media/downloads/ or local dir containing csv files) app.rebrickable_downloads_url: 'http://rebrickable.com/media/downloads/' - app.ld_library_download_url: 'http://www.ldraw.org/library/updates/completeCA.zip' + app.ld_library_download_url: 'http://www.ldraw.org/library/updates/complete.zip' app.media_root: "%kernel.root_dir%/../var/media/" diff --git a/src/AppBundle/Controller/ModelController.php b/src/AppBundle/Controller/ModelController.php index 770ce3e..82c8ec2 100644 --- a/src/AppBundle/Controller/ModelController.php +++ b/src/AppBundle/Controller/ModelController.php @@ -36,13 +36,13 @@ class ModelController extends Controller { $modelSearch = new ModelSearch(); - $form = $formFactory->createNamedBuilder('', ModelSearchType::class, $modelSearch)->getForm(); + $form = $formFactory->createNamedBuilder('model', ModelSearchType::class, $modelSearch)->getForm(); $form->handleRequest($request); /** @var Paginator $paginator */ $paginator = $this->get('knp_paginator'); $models = $paginator->paginate( - $searchService->searchModels($modelSearch), + $searchService->searchModels($modelSearch,500), $request->query->getInt('page', 1)/*page number*/, $request->query->getInt('limit', 30)/*limit per page*/ ); diff --git a/src/AppBundle/Service/Loader/ModelLoader.php b/src/AppBundle/Service/Loader/ModelLoader.php index ea400fe..8740e55 100644 --- a/src/AppBundle/Service/Loader/ModelLoader.php +++ b/src/AppBundle/Service/Loader/ModelLoader.php @@ -45,9 +45,6 @@ class ModelLoader extends BaseLoader /** @var RelationMapper */ private $relationMapper; - /** @var string */ - private $LDLibraryUrl; - /** @var bool */ private $rewrite = false; @@ -90,6 +87,12 @@ class ModelLoader extends BaseLoader } } + /** + * Download library form $url, unzip archive and return directory path with library + * + * @param $url + * @return bool|string + */ public function downloadLibrary($url) { $this->writeOutput([ @@ -116,6 +119,11 @@ class ModelLoader extends BaseLoader $this->writeOutput(['LDraw libary downloaded']); + // return ldraw directory if in zip file + if(file_exists($temp_dir.'/ldraw/')) { + return $temp_dir.'/ldraw/'; + } + return $temp_dir; } @@ -160,6 +168,7 @@ class ModelLoader extends BaseLoader ]); $files = $this->ldrawLibraryContext->listContents('parts', false); + $this->initProgressBar(count($files)); $index = 0; @@ -274,7 +283,7 @@ class ModelLoader extends BaseLoader try { // update model only if newer version - if (!$model->getModified() || ($model->getModified() < $modelArray['modified'])) { + if ($this->rewrite || ($model->getModified() < $modelArray['modified'])) { $stl = $this->stlConverter->datToStl($file, $this->rewrite)->getPath(); $model->setPath($stl); diff --git a/src/AppBundle/Service/Stl/StlConverterService.php b/src/AppBundle/Service/Stl/StlConverterService.php index ec0ec31..db51c8d 100644 --- a/src/AppBundle/Service/Stl/StlConverterService.php +++ b/src/AppBundle/Service/Stl/StlConverterService.php @@ -83,6 +83,7 @@ class StlConverterService '-LDrawDir='.$this->ldrawLibraryContext->getAdapter()->getPathPrefix(), '-ExportFiles=1', '-ExportSuffix=.stl', + '-UseQualityStuds=1', '-ExportsDir='.$this->mediaFilesystem->getAdapter()->getPathPrefix().'models', ]);