Limit graphic stats to 6 months by default, some performance query improvements

This commit is contained in:
Deon George
2021-12-03 11:24:23 +11:00
parent bf57f151d5
commit 10afd6f3a4
5 changed files with 29 additions and 6 deletions

View File

@@ -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]]
]);
}