<commit_before><?php

namespace Mapbender\MonitoringBundle\EventListener;
use Symfony\Component\EventDispatcher\Event;

class WmsListListener {

    protected $doctrine;

    public function __construct($doctrine) {
        $this->doctrine = $doctrine;
    }


    public function onWmsListLoaded(Event $event){
        $repository = $this->doctrine
            ->getRepository('Mapbender\MonitoringBundle\Entity\MonitoringDefinition');
        $data = array(); 
        $wmsIds = array();
        foreach($event->getWmsList() as $wms){
            $wmsIds[] = $wms->getId();
            $data[$wms->getId()] = "unmonitored";
        }
        $mds = $repository->findBy(array(
            "typeId" =>$wmsIds,
            "type" => get_class(new \Mapbender\WmsBundle\Entity\WMSService())
        ));
        foreach($mds as $md){
            if($lastJob = $md->getLastMonitoringJob()){
                if ($lastJob->getStatus() == "SUCCESS"){
                    $data[$md->getTypeId()] = 
                        '<span class="monitoring success">Everything is fine</span>';
                }else{
                    $data[$md->getTypeId()] = 
                        '<span class="monitoring failure">Something is broken</span>';

                }
            }else{
                $data[$md->getTypeId()] = '<span class="monitoring success">No runs yet</span>';
            }
        } 
        $event->addColumn("status",$data);
    }
}<commit_msg>Fix for the case that no WMS are registered<commit_after><?php

namespace Mapbender\MonitoringBundle\EventListener;
use Symfony\Component\EventDispatcher\Event;

class WmsListListener {

    protected $doctrine;

    public function __construct($doctrine) {
        $this->doctrine = $doctrine;
    }


    public function onWmsListLoaded(Event $event){
        $repository = $this->doctrine
            ->getRepository('Mapbender\MonitoringBundle\Entity\MonitoringDefinition');
        $data = array(); 
        $wmsIds = array();
        foreach($event->getWmsList() as $wms){
            $wmsIds[] = $wms->getId();
            $data[$wms->getId()] = "unmonitored";
        }
        if( count($wmsIds) < 1){
            return;
        }
        $mds = $repository->findBy(array(
            "typeId" =>$wmsIds,
            "type" => get_class(new \Mapbender\WmsBundle\Entity\WMSService())
        ));
        foreach($mds as $md){
            if($lastJob = $md->getLastMonitoringJob()){
                if ($lastJob->getStatus() == "SUCCESS"){
                    $data[$md->getTypeId()] = 
                        '<span class="monitoring success">Everything is fine</span>';
                }else{
                    $data[$md->getTypeId()] = 
                        '<span class="monitoring failure">Something is broken</span>';

                }
            }else{
                $data[$md->getTypeId()] = '<span class="monitoring success">No runs yet</span>';
            }
        } 
        $event->addColumn("status",$data);
    }
}
{'fraction_non_alphanumeric': 0.15018315018315018, 'fraction_numerical': 0.000333000333000333, 'mean_word_length': 1.9654491609081934, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7659732', 'n_tokens_mistral': 865, 'n_tokens_neox': 844, 'n_words': 148}