Limit graphic stats to 6 months by default, some performance query improvements
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
trait UseMongo
|
||||
{
|
||||
@@ -56,11 +57,21 @@ trait UseMongo
|
||||
if (! is_array($values))
|
||||
throw new \Exception('Where values must be an array.');
|
||||
|
||||
$where_condition[$key] = ['$in' => $values];
|
||||
switch ($x=Arr::get($values,0)) {
|
||||
case '$gt':
|
||||
case '$gte':
|
||||
$where_condition[$key] = [ $x => Arr::get($values,1)];
|
||||
break;
|
||||
|
||||
case '$in':
|
||||
default:
|
||||
$where_condition[$key] = ['$in' => $values];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$query->push([
|
||||
'$match' => $where_condition
|
||||
'$match' => [ '$and'=> [$where_condition]]
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user