<?php

namespace App\Services;

use App\Enums\ProcessGeneralState;
use App\Models\Notification;
use App\Models\Process;
use App\Repositories\DashboardComunityRepository;
use Config\Database;
use PDO;

class DashboardComunityService
{

    protected DashboardComunityRepository $processRepository;

    public function __construct() 
    {
        $this->processRepository = new DashboardComunityRepository();
    }

    public function getResponsesSummaryByType($userId)
    {
        return $this->processRepository->getResponsesSummaryByType($userId);
    }

    public function getProcessSummaryByState($userId)
    {
        return $this->processRepository->getProcessSummaryByState($userId);
    }

    public function getLastProcesses($userId, $limit = 3)
    {
        return $this->processRepository->getLastProcesses($userId, $limit);
    }

    public function getLastNotifications($userId, $limit = 3)
    {
        $rows = $this->processRepository->getLastNotifications($userId, $limit);

        $notifications = [];

        foreach ($rows as $row) {
            $notifications[] = new Notification($row);
        }

        return $notifications;
    }

}