Parcourir la source

Cambio en sincronizado acumulado

ElPoteito il y a 2 ans
Parent
commit
06b9747527
1 fichiers modifiés avec 18 ajouts et 2 suppressions
  1. 18 2
      commands/EventoController.php

+ 18 - 2
commands/EventoController.php

@@ -7,6 +7,9 @@ use app\models\DependenciaLider;
 use app\models\Notificacion;
 use app\models\NotificacionUsuario;
 use common\data\Respuesta;
+use DateTime;
+use Google\Cloud\Core\Timestamp;
+use Kreait\Firebase\Firestore;
 use v1\models\Dependencia;
 use v1\models\Evento;
 use v1\models\EventoAccion;
@@ -426,13 +429,26 @@ class EventoController extends Controller {
     $ultimaFecha = null;
     $limite = 100; // 1000;
     $continuar = true;
+    
+    $fechaActual = new DateTime();
+    $finFirebase = new Timestamp($fechaActual);
+
+    $this->stdout("fechaFin: {$finFirebase} \n");
+
+    $semanaPasada = new DateTime('-1 week');
+    $inicioFirebase = new Timestamp($semanaPasada);
+    $this->stdout("fechaFin: {$finFirebase} \n");
     do {
       $this->stdout("Sincronizando ...");
       $ref = $firestore->collection("eventos")
-        ->where("sincronizado", "==", null)
-        ->orderBy("timestamp", "ASC")
+        ->where("timestamp", ">=", $inicioFirebase)
+        ->where("timestamp", "<=", $finFirebase)
+        ->orderBy("timestamp", "DESC")
         ->limit($limite);
 
+      $documentos = $ref->documents()->size();
+      $this->stdout("Total documentos: {$documentos} \n");
+
       if ($ultimaFecha !== null) {
         $ref = $ref->startAt([$ultimaFecha]);
       }