File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public function actionSyncToDb()
6767 */
6868 public function actionUpdateExpired ()
6969 {
70- $ packages = $ this ->packageRepository ->getExpired ();
70+ $ packages = $ this ->packageRepository ->getExpiredForUpdate ();
7171
7272 foreach ($ packages as $ package ) {
7373 $ package ->load ();
Original file line number Diff line number Diff line change @@ -55,10 +55,22 @@ public function update(AssetPackage $package)
5555 {
5656 return $ this ->db ->createCommand ()->update ('package ' , [
5757 'last_update ' => $ package ->getUpdateTime ()
58- ], [
58+ ], $ this ->getWhereCondition ($ package ))->execute ();
59+ }
60+
61+ public function markAvoided (AssetPackage $ package )
62+ {
63+ $ this ->db ->createCommand ()->update ('package ' , [
64+ 'is_avoided ' => true
65+ ], $ this ->getWhereCondition ($ package ))->execute ();
66+ }
67+
68+ protected function getWhereCondition (AssetPackage $ package )
69+ {
70+ return [
5971 'type ' => $ package ->getType (),
6072 'name ' => $ package ->getName (),
61- ])-> execute () ;
73+ ];
6274 }
6375
6476 /**
@@ -76,12 +88,13 @@ public function exists(AssetPackage $package)
7688 /**
7789 * @return \hiqdev\assetpackagist\models\AssetPackage[]
7890 */
79- public function getExpired ()
91+ public function getExpiredForUpdate ()
8092 {
8193 $ rows = (new Query ())
8294 ->from ('package ' )
8395 ->where (['< ' , 'last_update ' , time () - 60 * 60 * 24 * 7 ]) // Older than 7 days
8496 ->andWhere (['not ' , ['last_update ' => null ]])
97+ ->andWhere (['is_avoided ' => null ])
8598 ->all ();
8699
87100 return $ this ->hydrate ($ rows );
You can’t perform that action at this time.
0 commit comments