|
@@ -775,11 +775,17 @@ class EventoController extends Controller {
|
|
|
"tag"
|
|
"tag"
|
|
|
])
|
|
])
|
|
|
->from("Evento")
|
|
->from("Evento")
|
|
|
- ->andWhere([">=", "fechaFinal", new Expression("now()-interval '7 days'")])
|
|
|
|
|
|
|
+ ->andWhere([">=", "fechaFinal", new Expression("now() - interval '7 days'")])
|
|
|
->groupBy(["tag", "nombre"])
|
|
->groupBy(["tag", "nombre"])
|
|
|
->indexBy("tag")
|
|
->indexBy("tag")
|
|
|
->column();
|
|
->column();
|
|
|
|
|
|
|
|
|
|
+ $totalEventos = count($eventos);
|
|
|
|
|
+ if($totalEventos === 0) {
|
|
|
|
|
+ # ¿Si no hubo eventos en el período de tiempo también hay que avisar?
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$query2 = (new Query())
|
|
$query2 = (new Query())
|
|
|
->select([
|
|
->select([
|
|
|
"tag",
|
|
"tag",
|
|
@@ -835,7 +841,8 @@ class EventoController extends Controller {
|
|
|
return (new Respuesta($notificacion))
|
|
return (new Respuesta($notificacion))
|
|
|
->mensaje("Hubo un problema al generar la notificación");
|
|
->mensaje("Hubo un problema al generar la notificación");
|
|
|
}
|
|
}
|
|
|
- $notificacion->refresh();
|
|
|
|
|
|
|
+ # TODO: Revisar si es necesario consultar la información del modelo
|
|
|
|
|
+ # $notificacion->refresh();
|
|
|
|
|
|
|
|
foreach ($aux as $usuario) {
|
|
foreach ($aux as $usuario) {
|
|
|
$notificacionUsuario = new NotificacionUsuario();
|
|
$notificacionUsuario = new NotificacionUsuario();
|
|
@@ -844,50 +851,40 @@ class EventoController extends Controller {
|
|
|
$notificacionUsuario->idUsuario = $usuario['id'];
|
|
$notificacionUsuario->idUsuario = $usuario['id'];
|
|
|
$notificacionUsuario->nombre = $usuario['nombreUsuario'];
|
|
$notificacionUsuario->nombre = $usuario['nombreUsuario'];
|
|
|
$notificacionUsuario->telefono = $usuario['telefono'];
|
|
$notificacionUsuario->telefono = $usuario['telefono'];
|
|
|
- if (count($usuario["eventosParticipo"]) === count($eventos)){
|
|
|
|
|
- $notificacionUsuario->parametros = [
|
|
|
|
|
- [
|
|
|
|
|
- "type" => "text",
|
|
|
|
|
- "text" => count($usuario["eventosParticipo"])."/".count($eventos). "eventos,"
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # Es mejor guardar el valor del count en lugar de evaluarlo multiples veces
|
|
|
|
|
+ $totalParticipaciones = count($usuario["eventosParticipo"]);
|
|
|
|
|
+
|
|
|
|
|
+ $parametros = [
|
|
|
|
|
+ [
|
|
|
|
|
+ "type" => "text",
|
|
|
|
|
+ "text" => "{$totalParticipaciones}/{$totalEventos} eventos"
|
|
|
|
|
+ ],
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ if ($totalParticipaciones === $totalEventos){
|
|
|
|
|
+ $parametros[] = [
|
|
|
[
|
|
[
|
|
|
"type" => "text",
|
|
"type" => "text",
|
|
|
"text" => "gracias por tu"
|
|
"text" => "gracias por tu"
|
|
|
]
|
|
]
|
|
|
];
|
|
];
|
|
|
- } else if (count($usuario["eventosParticipo"]) > 0 && count($usuario["eventosParticipo"]) < count($eventos)) {
|
|
|
|
|
- $notificacionUsuario->parametros = [
|
|
|
|
|
- [
|
|
|
|
|
- "type" => "text",
|
|
|
|
|
- "text" => count($usuario["eventosParticipo"])."/".count($eventos). "eventos,"
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ } else if ($totalParticipaciones > 0) {
|
|
|
|
|
+ $parametros[] = [
|
|
|
[
|
|
[
|
|
|
"type" => "text",
|
|
"type" => "text",
|
|
|
"text" => "gracias por tu participación. Vamos por el 100% de"
|
|
"text" => "gracias por tu participación. Vamos por el 100% de"
|
|
|
]
|
|
]
|
|
|
];
|
|
];
|
|
|
- } else if (count($usuario["eventosParticipo"]) === 0) {
|
|
|
|
|
- $notificacionUsuario->parametros = [
|
|
|
|
|
- [
|
|
|
|
|
- "type" => "text",
|
|
|
|
|
- "text" => count($usuario["eventosParticipo"])."/".count($eventos). "eventos."
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $parametros[] = [
|
|
|
[
|
|
[
|
|
|
"type" => "text",
|
|
"type" => "text",
|
|
|
"text" => "Vamos por el 100% de"
|
|
"text" => "Vamos por el 100% de"
|
|
|
]
|
|
]
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
- /* $notificacionUsuario->parametros = [
|
|
|
|
|
- [
|
|
|
|
|
- "type" => "text",
|
|
|
|
|
- "text" => count($usuario["eventosParticipo"])."/".count($eventos)
|
|
|
|
|
- ],
|
|
|
|
|
- [
|
|
|
|
|
- "type" => "text",
|
|
|
|
|
- "text" => "gracias por tu"
|
|
|
|
|
- ]
|
|
|
|
|
- ]; */
|
|
|
|
|
|
|
+ $notificacionUsuario->parametros = $parametros;
|
|
|
|
|
|
|
|
if (!$notificacionUsuario->save()) {
|
|
if (!$notificacionUsuario->save()) {
|
|
|
return (new Respuesta($notificacionUsuario))
|
|
return (new Respuesta($notificacionUsuario))
|