<commit_before><?php

namespace Modl;

class InfoDAO extends SQL
{
    function setOccupantsCount($server, $node, $count)
    {
        $this->_sql = '
            update info
            set occupants = :occupants
            where
                info.server = :server
                and info.node = :node';

        $this->prepare(
            'Info',
            [
                'server' => $server,
                'node' => $node,
                'occupants' => $count
            ]
        );

        return $this->run('Info');
    }

    function get($server, $node)
    {
        $this->_sql = '
            select * from info
            left outer join (
                select node, count(node) as num from postn
                where origin = :server
                group by node) as p
            on p.node = info.node
            where
                info.server = :server
                and info.node = :node';

        $this->prepare(
            'Info',
            [
                'server' => $server,
                'node' => $node
            ]
        );

        return $this->run('Info', 'item');
    }

    function getItems($server = false, $limitf = false, $limitr = false)
    {
        $this->_sql = '
            select *, postn.published from info
            left outer join (
                select node, count(node) as num from postn
            ';

        if($server) {
            $this->_sql .= '
                where origin = :server';
        }

        $this->_sql .= '
                group by node) as p
            on p.node = info.node
            left outer join (
                select origin, node, max(published) as published
                from postn
                group by origin, node
            ) as postn on postn.origin = info.server
              and postn.node = info.node
            left outer join (
                select node, count(node) as sub from subscription';

        if($server) {
            $this->_sql .= '
                where server = :server';
        }

        $this->_sql .= '
                group by node
            ) as sub
              on sub.node = info.node
            left outer join (select server, node, subscription from subscription where jid = :jid)
                as s on s.server = info.server
                and s.node = info.node
            where info.node != \'\'<commit_msg>Enfore pubsub leafs in InfoDAO getItems<commit_after><?php

namespace Modl;

class InfoDAO extends SQL
{
    function setOccupantsCount($server, $node, $count)
    {
        $this->_sql = '
            update info
            set occupants = :occupants
            where
                info.server = :server
                and info.node = :node';

        $this->prepare(
            'Info',
            [
                'server' => $server,
                'node' => $node,
                'occupants' => $count
            ]
        );

        return $this->run('Info');
    }

    function get($server, $node)
    {
        $this->_sql = '
            select * from info
            left outer join (
                select node, count(node) as num from postn
                where origin = :server
                group by node) as p
            on p.node = info.node
            where
                info.server = :server
                and info.node = :node';

        $this->prepare(
            'Info',
            [
                'server' => $server,
                'node' => $node
            ]
        );

        return $this->run('Info', 'item');
    }

    function getItems($server = false, $limitf = false, $limitr = false)
    {
        $this->_sql = '
            select *, postn.published from info
            left outer join (
                select node, count(node) as num from postn
            ';

        if($server) {
            $this->_sql .= '
                where origin = :server';
        }

        $this->_sql .= '
                group by node) as p
            on p.node = info.node
            left outer join (
                select origin, node, max(published) as published
                from postn
                group by origin, node
            ) as postn on postn.origin = info.server
              and postn.node = info.node
            left outer join (
                select node, count(node) as sub from subscription';

        if($server) {
            $this->_sql .= '
                where server = :server';
        }

        $this->_sql .= '
                group by node
            ) as sub
              on sub.node = info.node
            left outer join (select server, node, subscription from subscription where jid = :jid)
                as s on s.server = info.server
                and s.node = info.node
            where info.node != \'\'
                and info.category = \'pubsub\'
                and info.type = \'leaf\'
{'fraction_non_alphanumeric': 0.10199918400652795, 'fraction_numerical': 0.0, 'mean_word_length': 1.09888698630137, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '635122', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1226, 'n_words': 373}