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