File tree 2 files changed +17
-4
lines changed
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public function actionSyncToDb()
67
67
*/
68
68
public function actionUpdateExpired ()
69
69
{
70
- $ packages = $ this ->packageRepository ->getExpired ();
70
+ $ packages = $ this ->packageRepository ->getExpiredForUpdate ();
71
71
72
72
foreach ($ packages as $ package ) {
73
73
$ package ->load ();
Original file line number Diff line number Diff line change @@ -55,10 +55,22 @@ public function update(AssetPackage $package)
55
55
{
56
56
return $ this ->db ->createCommand ()->update ('package ' , [
57
57
'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 [
59
71
'type ' => $ package ->getType (),
60
72
'name ' => $ package ->getName (),
61
- ])-> execute () ;
73
+ ];
62
74
}
63
75
64
76
/**
@@ -76,12 +88,13 @@ public function exists(AssetPackage $package)
76
88
/**
77
89
* @return \hiqdev\assetpackagist\models\AssetPackage[]
78
90
*/
79
- public function getExpired ()
91
+ public function getExpiredForUpdate ()
80
92
{
81
93
$ rows = (new Query ())
82
94
->from ('package ' )
83
95
->where (['< ' , 'last_update ' , time () - 60 * 60 * 24 * 7 ]) // Older than 7 days
84
96
->andWhere (['not ' , ['last_update ' => null ]])
97
+ ->andWhere (['is_avoided ' => null ])
85
98
->all ();
86
99
87
100
return $ this ->hydrate ($ rows );
You can’t perform that action at this time.
0 commit comments