Skip to content

Commit

Permalink
#35 wip calculate series
Browse files Browse the repository at this point in the history
digedag committed Sep 29, 2024
1 parent 18d772c commit a74a64f
Showing 36 changed files with 2,321 additions and 106 deletions.
9 changes: 9 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -13,6 +13,15 @@
'phpdoc_align' => false,
'no_superfluous_phpdoc_tags' => false,
'single_line_comment_spacing' => false,
'global_namespace_import' => [
'import_classes' => true, 'import_constants' => false, 'import_functions' => false
],
'phpdoc_separation' => [
'skip_unlisted_annotations' => true,
],
'trailing_comma_in_multiline' => [
'elements' => ['arrays'],
],
])
->setLineEnding("\n")
;
123 changes: 123 additions & 0 deletions Classes/Command/CalculateSeriesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

namespace System25\T3sports\Command;

use Contrib\Doctrine\Common\Collections\Collection;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use System25\T3sports\Model\Club;
use System25\T3sports\Model\Fixture;
use System25\T3sports\Model\Series;
use System25\T3sports\Series\SeriesBag;
use System25\T3sports\Series\SeriesCalculationVisitorInterface;
use System25\T3sports\Series\SeriesCalculator;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche
* Contact: [email protected]
* All rights reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************/

/**
* Default filter for coach statistics.
*
* @author Rene Nitzsche
*/
class CalculateSeriesCommand extends Command implements SeriesCalculationVisitorInterface
{
private $seriesCalculator;
/** @var OutputInterface */
private $output;
/** @var ProgressBar */
private $clubProgress;
/** @var ProgressBar */
private $matchProgress;

public function __construct(SeriesCalculator $seriesCalculator)
{
parent::__construct(null);
$this->seriesCalculator = $seriesCalculator;
}

protected function configure()
{
$this->addOption('uid', null, InputOption::VALUE_REQUIRED, 'UID of series to calculate.');
$this->setHelp('Calculate match series in T3sports.');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$output->writeln('<info>Calculate series.</info>');
$uid = $input->getOption('uid');
if ($uid === null) {
$output->writeln('<error>Option --uid missing.</error>');
}
$uid = (int) $uid;

$this->seriesCalculator->calculate($uid, $this);

$this->clubProgress->finish();
$this->matchProgress->finish();
// Do awesome stuff
return Command::SUCCESS;
}

public function seriesLoaded(Series $series, array $clubUids): void
{
$section = $this->output->section();
$this->output->writeln(sprintf('<info>Process "%s" for %d clubs</info>', $series->getProperty('label'), count($clubUids)));
$this->clubProgress = new ProgressBar($section, count($clubUids));
$this->clubProgress->setFormat('very_verbose');
$this->clubProgress->start();
}

public function matchesLoaded(Collection $matches): void
{
if ($this->matchProgress) {
$this->matchProgress->finish();
}
$section = $this->output->section();
$this->matchProgress = new ProgressBar($section, count($matches));
$this->matchProgress->setFormat('debug');
$this->matchProgress->start();
}

public function clubProcessed(Club $club, SeriesBag $seriesBag): void
{
$this->clubProgress->advance();
$firstMatch = $seriesBag->getBestSeries()[0];
$lastMatch = $seriesBag->getBestSeries()[count($seriesBag->getBestSeries())-1];
$this->output->section()->writeln(sprintf('<info>Club (%s) %d series length: %d from %s to %s</info>',
$club->getName(),
$club->getUid(), count($seriesBag->getBestSeries()),
date('d.m.Y', $firstMatch->getProperty('date')),
date('d.m.Y', $lastMatch->getProperty('date'))
));
}

public function matchProcessed(Fixture $match): void
{
$this->matchProgress->advance();
}

}
30 changes: 30 additions & 0 deletions Classes/DependencyInjection/SeriesRulePass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace System25\T3sports\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use System25\T3sports\Series\SeriesRuleInterface;
use System25\T3sports\Series\SeriesRuleProvider;

class SeriesRulePass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
// always first check if the primary service is defined
if (!$container->has(SeriesRuleProvider::class)) {
return;
}

$definition = $container->findDefinition(SeriesRuleProvider::class);

// find all service IDs with the t3sports.stats.indexer tag
$taggedServices = $container->findTaggedServiceIds(SeriesRuleInterface::TAG);

foreach ($taggedServices as $id => $tags) {
// add the indexer to the IndexerProvider service
$definition->addMethodCall('addSeriesRule', [new Reference($id)]);
}
}
}
3 changes: 2 additions & 1 deletion Classes/DependencyInjection/StatsIndexerPass.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use System25\T3sports\Service\StatsIndexerProvider;
use System25\T3sports\StatsIndexer\StatsInterface;

class StatsIndexerPass implements CompilerPassInterface
{
@@ -19,7 +20,7 @@ public function process(ContainerBuilder $container): void
$definition = $container->findDefinition(StatsIndexerProvider::class);

// find all service IDs with the t3sports.stats.indexer tag
$taggedServices = $container->findTaggedServiceIds('t3sports.stats.indexer');
$taggedServices = $container->findTaggedServiceIds(StatsInterface::TAG);

foreach ($taggedServices as $id => $tags) {
// add the indexer to the IndexerProvider service
47 changes: 47 additions & 0 deletions Classes/Hooks/ClubSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace System25\T3sports\Hooks;

use Sys25\RnBase\Database\Query\Join;

/***************************************************************
* Copyright notice
*
* (c) 2010-2021 Rene Nitzsche
* Contact: [email protected]
* All rights reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************/

/**
* Make additional join for club search.
*
* @author Rene Nitzsche
*/
class ClubSearch
{
public function getTableMappingMatch(&$params, $parent)
{
$params['tableMapping']['SERIES_SCOPE_MM'] = 'tx_t3sportstats_series_scope_mm';
}

public function getJoinsMatch(&$params, $parent)
{
if (isset($params['tableAliases']['SERIES_SCOPE_MM'])) {
$params['join'][] = new Join('CLUB', 'tx_t3sportstats_series_scope_mm', 'CLUB.uid = SERIES_SCOPE_MM.uid_foreign AND SERIES_SCOPE_MM.tablenames=\'tx_cfcleague_club\'', 'SERIES_SCOPE_MM');
}
}
}
55 changes: 55 additions & 0 deletions Classes/Model/Series.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace System25\T3sports\Model;

use Sys25\RnBase\Domain\Model\BaseModel;

/***************************************************************
* Copyright notice
*
* (c) 2010-2020 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Model for a match series definition record.
*/
class Series extends BaseModel
{
public function getTableName()
{
return 'tx_t3sportstats_series';
}

/**
* Returns the competition uid.
*
* @return int
*/
public function getCompetitionUid()
{
return $this->getProperty('competition');
}

public function getMatchUid()
{
return $this->getProperty('t3match');
}

}
44 changes: 44 additions & 0 deletions Classes/Model/SeriesResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace System25\T3sports\Model;

use Sys25\RnBase\Domain\Model\BaseModel;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Model for a match series result record.
*/
class SeriesResult extends BaseModel
{
public function getTableName()
{
return 'tx_t3sportstats_series_result';
}

public function getUniqueKey(): ?string
{
return $this->getProperty('uniquekey');
}
}
62 changes: 62 additions & 0 deletions Classes/Model/SeriesRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace System25\T3sports\Model;

use Exception;
use Sys25\RnBase\Domain\Model\BaseModel;
use System25\T3sports\Series\SeriesRuleInterface;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Model for a match series rule record.
*/
class SeriesRule extends BaseModel
{
private $rule = null;

public function getTableName()
{
return 'tx_t3sportstats_series_rule';
}

public function setRule(SeriesRuleInterface $rule)
{
$this->rule = $rule;
}

public function isSatisfied(Fixture $match, bool $isHome): bool
{
return $this->getRule()->isSatified($match, $isHome, $this->getProperty('config'));
}

private function getRule(): SeriesRuleInterface
{
if ($this->rule === null) {
throw new Exception('Missing rule implementation for '.$this->getUid());
}

return $this->rule;
}
}
41 changes: 41 additions & 0 deletions Classes/Repository/SeriesRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace System25\T3sports\Repository;

use Sys25\RnBase\Domain\Repository\PersistenceRepository;
use System25\T3sports\Search\SeriesSearch;

/***************************************************************
* Copyright notice
*
* (c) 2017-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* @author Rene Nitzsche
*/
class SeriesRepository extends PersistenceRepository
{
public function getSearchClass()
{
return SeriesSearch::class;
}

}
97 changes: 97 additions & 0 deletions Classes/Repository/SeriesResultRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

namespace System25\T3sports\Repository;

use Contrib\Doctrine\Common\Collections\Collection;
use Sys25\RnBase\Domain\Repository\PersistenceRepository;
use System25\T3sports\Model\Club;
use System25\T3sports\Model\Series;
use System25\T3sports\Model\SeriesResult;
use System25\T3sports\Search\SeriesResultSearch;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;

/***************************************************************
* Copyright notice
*
* (c) 2017-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* @author Rene Nitzsche
*/
class SeriesResultRepository extends PersistenceRepository
{
public function getSearchClass()
{
return SeriesResultSearch::class;
}

/**
* @return Collection<SeriesResult>
*/
public function findBySeries(Series $series): Collection
{
return $this->search(['SERIESRESULT.parentid' => [OP_EQ_INT => $series->getUid()]], []);
}

/**
* @return Collection<SeriesResult>
*/
public function findBySeriesAndClub(Series $series, Club $club): Collection
{
return $this->search([
'SERIESRESULT.parentid' => [OP_EQ_INT => $series->getUid()],
'SERIESRESULT.club' => [OP_EQ_INT => $club->getUid()],
], []);
}

/**
*
* @param Series $series
* @param mixed $clubUid
* @return int
*/
public function clearSeriesResultByClub(Series $series, $clubUid): int
{
$result = 0;
// Zuerst die Referenzen auf die Spiele entfernen
$existingSeries = $this->findBySeriesAndClub($series, $clubUid);
foreach($existingSeries as $existing) {
$result += $this->clearSeriesResult($existing);
}

return $result;
}

public function clearSeriesResult(SeriesResult $seriesResult): int
{
// Zuerst die Referenzen auf die Spiele entfernen
$this->getConnection()->doDelete('tx_t3sportstats_series_result_mm', function(QueryBuilder $qb) use ($seriesResult) {
$qb->where('uid_local = :seriesId')
->setParameter('seriesId', $seriesResult->getUid());
});

$fields = [
'SERIESRESULT.uid' => [OP_EQ_INT => $seriesResult->getUid()],
];

return $this->delete($fields);
}
}
47 changes: 47 additions & 0 deletions Classes/Repository/SeriesRuleRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace System25\T3sports\Repository;

use Sys25\RnBase\Domain\Collection\BaseCollection;
use Sys25\RnBase\Domain\Repository\PersistenceRepository;
use System25\T3sports\Model\Series;
use System25\T3sports\Search\SeriesRuleSearch;

/***************************************************************
* Copyright notice
*
* (c) 2017-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* @author Rene Nitzsche
*/
class SeriesRuleRepository extends PersistenceRepository
{
public function getSearchClass()
{
return SeriesRuleSearch::class;
}

public function findBySeries(Series $series): BaseCollection
{
return $this->search(['SERIESRULE.parentid' => [OP_EQ_INT => $series->getUid()]], []);
}
}
88 changes: 88 additions & 0 deletions Classes/Search/SeriesResultSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

namespace System25\T3sports\Search;

use Sys25\RnBase\Database\Query\Join;
use Sys25\RnBase\Search\SearchBase;
use Sys25\RnBase\Utility\Misc;
use System25\T3sports\Model\SeriesResult;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche
* Contact: rene@system25.de
* All rights reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************/

/**
* Class to search series results from database.
*
* @author Rene Nitzsche
*/
class SeriesResultSearch extends SearchBase
{
protected function getTableMappings()
{
$tableMapping = [];
$tableMapping['SERIESRESULT'] = $this->getBaseTable();
$tableMapping['SERIES'] = 'tx_t3sportstats_series';

// Hook to append other tables
Misc::callHook('t3sportstats', 'search_SeriesResult_getTableMapping_hook', [
'tableMapping' => &$tableMapping,
], $this);

return $tableMapping;
}

protected function useAlias()
{
return true;
}

protected function getBaseTableAlias()
{
return 'SERIESRESULT';
}

protected function getBaseTable()
{
return 'tx_t3sportstats_series_result';
}

public function getWrapperClass()
{
return SeriesResult::class;
}

protected function getJoins($tableAliases)
{
$join = [];
if (isset($tableAliases['SERIES'])) {
$join[] = new Join('SERIESRESULT', 'tx_t3sportstats_series', 'SERIES.uid = SERIESRESULT.parentid', 'SERIES');
}

// Hook to append other tables
Misc::callHook('t3sportstats', 'search_SeriesResult_getJoins_hook', [
'join' => &$join,
'tableAliases' => $tableAliases,
], $this);

return $join;
}
}
89 changes: 89 additions & 0 deletions Classes/Search/SeriesRuleSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

namespace System25\T3sports\Search;

use Sys25\RnBase\Database\Query\Join;
use Sys25\RnBase\Search\SearchBase;
use Sys25\RnBase\Utility\Misc;
use System25\T3sports\Model\Series;
use System25\T3sports\Model\SeriesRule;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche
* Contact: rene@system25.de
* All rights reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************/

/**
* Class to search player stats from database.
*
* @author Rene Nitzsche
*/
class SeriesRuleSearch extends SearchBase
{
protected function getTableMappings()
{
$tableMapping = [];
$tableMapping['SERIESRULE'] = $this->getBaseTable();
$tableMapping['SERIES'] = 'tx_t3sportstats_series';

// Hook to append other tables
Misc::callHook('t3sportstats', 'search_SeriesRule_getTableMapping_hook', [
'tableMapping' => &$tableMapping,
], $this);

return $tableMapping;
}

protected function useAlias()
{
return true;
}

protected function getBaseTableAlias()
{
return 'SERIESRULE';
}

protected function getBaseTable()
{
return 'tx_t3sportstats_series_rule';
}

public function getWrapperClass()
{
return SeriesRule::class;
}

protected function getJoins($tableAliases)
{
$join = [];
if (isset($tableAliases['SERIES'])) {
$join[] = new Join('SERIESRULE', 'tx_t3sportstats_series', 'SERIES.uid = SERIESRULE.parentid', 'SERIES');
}

// Hook to append other tables
Misc::callHook('t3sportstats', 'search_SeriesRule_getJoins_hook', [
'join' => &$join,
'tableAliases' => $tableAliases,
], $this);

return $join;
}
}
102 changes: 102 additions & 0 deletions Classes/Search/SeriesSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php

namespace System25\T3sports\Search;

use Sys25\RnBase\Database\Query\Join;
use Sys25\RnBase\Search\SearchBase;
use Sys25\RnBase\Utility\Misc;
use System25\T3sports\Model\CoachStat;
use System25\T3sports\Model\Series;

/***************************************************************
* Copyright notice
*
* (c) 2010-2022 Rene Nitzsche
* Contact: rene@system25.de
* All rights reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************/

/**
* Class to search player stats from database.
*
* @author Rene Nitzsche
*/
class SeriesSearch extends SearchBase
{
protected function getTableMappings()
{
$tableMapping = [];
$tableMapping['SERIES'] = 'tx_t3sportstats_series';
$tableMapping['MATCH'] = 'tx_cfcleague_games';
$tableMapping['COMPETITION'] = 'tx_cfcleague_competition';
$tableMapping['CLUB'] = 'tx_cfcleague_club';
// Hook to append other tables
Misc::callHook('t3sportstats', 'search_Series_getTableMapping_hook', [
'tableMapping' => &$tableMapping,
], $this);

return $tableMapping;
}

protected function useAlias()
{
return true;
}

protected function getBaseTableAlias()
{
return 'SERIES';
}

protected function getBaseTable()
{
return 'tx_t3sportstats_series';
}

public function getWrapperClass()
{
return Series::class;
}

protected function getJoins($tableAliases)
{
$join = [];
if (isset($tableAliases['MATCH'])) {
$join[] = new Join('COACHSTAT', 'tx_cfcleague_games', 'MATCH.uid = COACHSTAT.t3match', 'MATCH');
}
if (isset($tableAliases['COACH'])) {
$join[] = new Join('COACHSTAT', 'tx_cfcleague_profiles', 'COACH.uid = COACHSTAT.coach', 'COACH');
}
if (isset($tableAliases['COMPETITION'])) {
$join[] = new Join('COACHSTAT', 'tx_cfcleague_competition', 'COMPETITION.uid = COACHSTAT.competition', 'COMPETITION');
}
if (isset($tableAliases['CLUB'])) {
$join[] = new Join('COACHSTAT', 'tx_cfcleague_club', 'CLUB.uid = COACHSTAT.club', 'CLUB');
}
if (isset($tableAliases['CLUBOPP'])) {
$join[] = new Join('COACHSTAT', 'tx_cfcleague_club', 'CLUBOPP.uid = COACHSTAT.clubopp', 'CLUBOPP');
}

// Hook to append other tables
Misc::callHook('t3sportstats', 'search_Series_getJoins_hook', [
'join' => &$join,
'tableAliases' => $tableAliases,
], $this);

return $join;
}
}
46 changes: 46 additions & 0 deletions Classes/Series/Rule/LostRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace System25\T3sports\Series\Rule;


/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Interface for series rule
*
*/
class LostRule extends MatchResultRule
{
const ALIAS = 'LOST_RULE';

public function getAlias(): string
{
return self::ALIAS;
}

protected function getStates(): array
{
return [self::RESULT_LOST];
}
}
66 changes: 66 additions & 0 deletions Classes/Series/Rule/MatchResultRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace System25\T3sports\Series\Rule;

use System25\T3sports\Model\Fixture;
use System25\T3sports\Model\Team;
use System25\T3sports\Series\SeriesRuleInterface;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Interface for series rule
*
*/
abstract class MatchResultRule implements SeriesRuleInterface
{
const RESULT_WIN = 'win';
const RESULT_LOST = 'lost';
const RESULT_DRAW = 'draw';

public function getTcaLabel(): string
{
return sprintf('LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_rule.%s', strtolower($this->getAlias()));
}

function setConfig($config): void
{

}

public function isSatified(Fixture $match, bool $isHome, $config): bool
{
$toto = $match->getToto();
$result = self::RESULT_DRAW;
if ($toto === 1) {
$result = $isHome ? self::RESULT_WIN : self::RESULT_LOST;
} elseif ($toto === 2) {
$result = $isHome ? self::RESULT_LOST : self::RESULT_WIN;
}

return in_array($result, $this->getStates());
}

abstract protected function getStates(): array;
}
46 changes: 46 additions & 0 deletions Classes/Series/Rule/NotLostRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace System25\T3sports\Series\Rule;


/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Interface for series rule
*
*/
class NotLostRule extends MatchResultRule
{
const ALIAS = 'NOT_LOST_RULE';

public function getAlias(): string
{
return self::ALIAS;
}

protected function getStates(): array
{
return [self::RESULT_WIN, self::RESULT_DRAW];
}
}
46 changes: 46 additions & 0 deletions Classes/Series/Rule/NotWonRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace System25\T3sports\Series\Rule;


/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Interface for series rule
*
*/
class NotWonRule extends MatchResultRule
{
const ALIAS = 'NOT_WON_RULE';

public function getAlias(): string
{
return self::ALIAS;
}

protected function getStates(): array
{
return [self::RESULT_LOST, self::RESULT_DRAW];
}
}
47 changes: 47 additions & 0 deletions Classes/Series/Rule/WinRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace System25\T3sports\Series\Rule;

use System25\T3sports\Series\SeriesRuleInterface;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Interface for series rule
*
*/
class WinRule extends MatchResultRule
{
const ALIAS = 'WIN_RULE';

public function getAlias(): string
{
return self::ALIAS;
}

protected function getStates(): array
{
return [self::RESULT_WIN];
}
}
103 changes: 103 additions & 0 deletions Classes/Series/SeriesBag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php

namespace System25\T3sports\Series;

use System25\T3sports\Model\Club;
use System25\T3sports\Model\Fixture;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Sammel-Container für Serien bei der Ermittlung.
*
*/
class SeriesBag
{
private $bestSeries = [];
private $currentSeries = [];
private $club;

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

public function appendToSeries(Fixture $match)
{
$this->currentSeries[] = $match;
}

public function breakSeries()
{
if (count($this->currentSeries) > count($this->bestSeries)) {
$this->bestSeries = $this->currentSeries;
}
$this->currentSeries = [];
}

/**
*
* @return Fixture[]
*/
public function getBestSeries(): array
{
return $this->bestSeries;
}

public function getClub(): ?Club
{
return $this->club;
}

public function getClubUid(): int
{
return $this->club->getUid();
}

public function getFirstMatch(): ?Fixture
{
return $this->bestSeries[0] ?? null;
}

public function getLastMatch(): ?Fixture
{
return $this->bestSeries[$this->getSize() - 1] ?? null;
}

public function getSize(): int
{
return count($this->bestSeries);
}

public function getHash(): string
{
$uids = [];

foreach($this->bestSeries as $fixture) {
$uids[] = $fixture->getUid();
}

return md5(implode(',', $uids));
}
}
43 changes: 43 additions & 0 deletions Classes/Series/SeriesCalculationVisitorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace System25\T3sports\Series;

use Contrib\Doctrine\Common\Collections\Collection;
use System25\T3sports\Model\Club;
use System25\T3sports\Model\Fixture;
use System25\T3sports\Model\Series;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Interface for series rule
*
*/
interface SeriesCalculationVisitorInterface
{
function seriesLoaded(Series $series, array $clubUids): void;
function clubProcessed(Club $club, SeriesBag $seriesBag): void;
function matchesLoaded(Collection $matches): void;
function matchProcessed(Fixture $match): void;
}
264 changes: 264 additions & 0 deletions Classes/Series/SeriesCalculator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
<?php

namespace System25\T3sports\Series;

use Contrib\Doctrine\Common\Collections\Collection;
use Exception;
use Sys25\RnBase\Database\Connection;
use System25\T3sports\Model\Club;
use System25\T3sports\Model\Fixture;
use System25\T3sports\Model\Repository\ClubRepository;
use System25\T3sports\Model\Repository\TeamRepository;
use System25\T3sports\Model\Series;
use System25\T3sports\Model\SeriesResult;
use System25\T3sports\Model\SeriesRule;
use System25\T3sports\Model\Team;
use System25\T3sports\Repository\SeriesRepository;
use System25\T3sports\Repository\SeriesResultRepository;
use System25\T3sports\Repository\SeriesRuleRepository;
use System25\T3sports\Service\MatchService;
use System25\T3sports\Utility\ServiceRegistry;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Service for accessing team information.
*
* @author Rene Nitzsche
*/
class SeriesCalculator
{
private $matchService;
private $seriesRepo;
private $seriesRuleRepo;
private $seriesResultRepo;
private $teamRepo;
private $clubRepo;
private $ruleProvider;
/** @var Connection */
private $dbConnection;

public function __construct(
SeriesRuleProvider $ruleProvider,
ClubRepository $clubRepo,
SeriesRepository $seriesRepo,
SeriesResultRepository $seriesResultRepo,
SeriesRuleRepository $seriesRuleRepo,
TeamRepository $teamRepo,
MatchService $matchService = null
) {
$this->ruleProvider = $ruleProvider;
$this->matchService = $matchService ?: ServiceRegistry::getMatchService();
$this->seriesRepo = $seriesRepo;
$this->seriesResultRepo = $seriesResultRepo;
$this->seriesRuleRepo = $seriesRuleRepo;
$this->teamRepo = $teamRepo;
$this->clubRepo = $clubRepo;
$this->dbConnection = Connection::getInstance();
}

/**
* (Re-)Calculate given series
*
* @param int $seriesUid
*/
public function calculate(int $seriesUid, SeriesCalculationVisitorInterface $visitor)
{
$series = $this->seriesRepo->findByUid($seriesUid);
if ($series === null) {
throw new Exception(sprintf('Match series with uid %d not found in database', $seriesUid));
}

$scopeRules = $this->seriesRuleRepo->findBySeries($series);
foreach($scopeRules as $scopeRule) {
/** @var SeriesRule $scopeRule */
$scopeRule->setRule(
$this->ruleProvider->getSeriesRuleByAlias($scopeRule->getProperty('rulealias'))
);
}

$clubs = $this->clubRepo->search(
['SERIES_SCOPE_MM.uid_local' => [OP_EQ_INT => $series->getUid()],],
['what' => 'CLUB.uid',]
);
$clubs = $clubs->map(function($item){ return $item['uid'];})->toArray();
$ageGroup = $series->getProperty('agegroup');

if ($visitor) {
$visitor->seriesLoaded($series, $clubs);
}

foreach($clubs as $clubUid) {
$club = $this->clubRepo->findByUid($clubUid);
$seriesBag = new SeriesBag($club);
$matches = $this->lookupMatches($clubUid, $ageGroup);
if ($visitor) {
$visitor->matchesLoaded($matches);
}

foreach($matches as $match) {
try {
if ($this->isRuleSatisfied($match, $scopeRules, $clubUid, $ageGroup)) {
$seriesBag->appendToSeries($match);
} else {
$seriesBag->breakSeries();
}
} catch (TeamNotFoundException $e) {
// This is okay
continue;
} finally {
if ($visitor) {
$visitor->matchProcessed($match);
}
}
}
$this->persistResult($seriesBag, $series);
if ($visitor) {
$visitor->clubProcessed($club, $seriesBag);
}
}
return;
}

private function persistResult(SeriesBag $seriesBag, Series $series): void
{
$existingSeries = $this->seriesResultRepo->findBySeriesAndClub($series, $seriesBag->getClub());
if ($existingSeries->count() > 1) {
// Das sollte nicht vorkommen. Also löschen wir alles weg.
$this->clearResult($existingSeries);
$existingSeries = $this->seriesResultRepo->findBySeriesAndClub($series, $seriesBag->getClub());
}

if ($seriesBag->getSize() < 2) {
$this->clearResult($existingSeries);

return;
}

/** @var SeriesResult $existingSeries */
$existingSeries = $existingSeries->first();

if ($existingSeries && $existingSeries->getUniqueKey() === $seriesBag->getHash()) {
// Es hat sich nix verändert.

return;
}

$this->clearResult($existingSeries);
$result = new SeriesResult();
$result->setProperty('club', $seriesBag->getClubUid());
$result->setProperty('firstmatch', $seriesBag->getFirstMatch()->getUid());
$result->setProperty('lastmatch', $seriesBag->getLastMatch()->getUid());
$result->setProperty('quantity', $seriesBag->getSize());
$result->setProperty('pid', $series->getPid());
$result->setProperty('parentid', $series->getUid());
$result->setProperty('parenttable', 'tx_t3sportstats_series');
$result->setProperty('uniquekey', $seriesBag->getHash());

$this->seriesResultRepo->persist($result);
foreach($seriesBag->getBestSeries() as $idx => $match) {
$this->dbConnection->doInsert('tx_t3sportstats_series_result_mm', [
'uid_local' => $result->getUid(),
'uid_foreign' => $match->getUid(),
'tablenames' => 'tx_cfcleague_games',
'sorting' => $idx,
'sorting_foreign' => 0,
]);
}
}

private function clearResult($seriesResults): void
{
if (!$seriesResults) {
return;
}

if (!($seriesResults instanceof Collection)) {
$seriesResults = [$seriesResults];
}

foreach($seriesResults as $seriesResult) {
$this->seriesResultRepo->clearSeriesResult($seriesResult);
}
}

/**
*
* @param Fixture $match
* @param Collection<SeriesRule> $rules
* @param mixed $clubUid
* @param mixed $ageGroupUid
* @return bool
*/
private function isRuleSatisfied(Fixture $match, Collection $rules, $clubUid, $ageGroupUid): bool
{
// Team ermitteln
$isHome = $this->isTeamHome($match, $clubUid, $ageGroupUid);

$isSatified = true;
foreach($rules as $rule) {
/** @var SeriesRule $rule */
if (!$rule->isSatisfied($match, $isHome)) {
return false;
}
}

return $isSatified;
}

private function isTeamHome($match, $clubUid, $ageGroupUid): bool
{
/** @var Team $team */
$team = $this->teamRepo->findByUid($match->getProperty('home'));
if ($team->getProperty('club') === $clubUid
&& ($team->getGroupUid() === $ageGroupUid || $team->getGroupUid() === 0)) {
return true;
}
/** @var Team $team */
$team = $this->teamRepo->findByUid($match->getProperty('guest'));
if ($team->getProperty('club') === $clubUid
&& ($team->getGroupUid() === $ageGroupUid || $team->getGroupUid() === 0)) {
return false;
}

throw new TeamNotFoundException(sprintf('Team for club %d not found in match %d', $clubUid, $match->getUid()));
}

private function lookupMatches($clubUid, $ageGroupUid): Collection
{
$builder = $this->matchService->getMatchTableBuilder();
$builder->setStatus(Fixture::MATCH_STATUS_FINISHED);
$builder->setAgeGroups($ageGroupUid);
$builder->setClubs(''.$clubUid);
$builder->setOrderByDate(false);
$builder->setCompetitionObligation(1);

$fields = $options = [];
$builder->getFields($fields, $options);
/** @var \Sys25\RnBase\Domain\Collection\BaseCollection $matches */
$matches = $this->matchService->search($fields, $options);

return $matches;
}
}
43 changes: 43 additions & 0 deletions Classes/Series/SeriesRuleInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace System25\T3sports\Series;

use System25\T3sports\Model\Club;
use System25\T3sports\Model\Fixture;
use System25\T3sports\Model\Team;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Interface for series rule
*
*/
interface SeriesRuleInterface
{
const TAG = 't3sports.stats.seriesrule';

function getAlias(): string;
function getTcaLabel(): string;
function isSatified(Fixture $match, bool $isHome, $config): bool;
}
84 changes: 84 additions & 0 deletions Classes/Series/SeriesRuleProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

namespace System25\T3sports\Series;

use Sys25\RnBase\Utility\Misc;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Zentrale Klasse für den Zugriff auf verschiedene Services.
*/
class SeriesRuleProvider implements \TYPO3\CMS\Core\SingletonInterface
{
private $rules = [];

/**
* Used by T3 versions without DI.
*
* @var SeriesRuleProvider
*/
private static $instance = null;

public function addSeriesRule(SeriesRuleInterface $rule)
{
$alias = $rule->getAlias();
$this->rules[$alias] = $rule;
}

/**
* @return SeriesRuleInterface
*/
public function getSeriesRuleByAlias(string $alias)
{
return $this->rules[$alias] ?? null;
}

/**
* Only used by T3 versions prior to 10.x.
*
* @return self
*/
public static function getInstance()
{
if (null === self::$instance) {
self::$instance = new self();
}

return self::$instance;
}

public function getRules4Tca(array &$config): void
{
$items = [];
foreach ($this->rules as $rule) {
$items[] = [
Misc::translateLLL($rule->getTCALabel()),
$rule->getAlias(),
];
}

$config['items'] = $items;
}
}
35 changes: 35 additions & 0 deletions Classes/Series/TeamNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace System25\T3sports\Series;

use Exception;

/***************************************************************
* Copyright notice
*
* (c) 2010-2024 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
*
*/
class TeamNotFoundException extends Exception
{
}
2 changes: 2 additions & 0 deletions Classes/StatsIndexer/StatsInterface.php
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@
*/
interface StatsInterface
{
const TAG = 't3sports.stats.indexer';

/**
* @return string
*/
5 changes: 4 additions & 1 deletion Configuration/Services.php
Original file line number Diff line number Diff line change
@@ -4,9 +4,12 @@

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use System25\T3sports\Series\SeriesRuleInterface;
use System25\T3sports\StatsIndexer\StatsInterface;

return function (ContainerConfigurator $container, ContainerBuilder $containerBuilder) {
$containerBuilder->registerForAutoconfiguration(StatsInterface::class)->addTag('t3sports.stats.indexer');
$containerBuilder->registerForAutoconfiguration(StatsInterface::class)->addTag(StatsInterface::TAG);
$containerBuilder->addCompilerPass(new DependencyInjection\StatsIndexerPass());
$containerBuilder->registerForAutoconfiguration(SeriesRuleInterface::class)->addTag(SeriesRuleInterface::TAG);
$containerBuilder->addCompilerPass(new DependencyInjection\SeriesRulePass());
};
6 changes: 6 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
@@ -11,3 +11,9 @@ services:
# public, damit das Autowiring beim Hook-Aufruf klappt. Gibt es ein Tag für Hooks?
System25\T3sports\Hooks\ClearStats:
public: true
System25\T3sports\Command\CalculateSeriesCommand:
tags:
- name: 'console.command'
command: 't3sports:stats:calculate-series'
schedulable: false
description: calculate a match series in T3sportstats
183 changes: 183 additions & 0 deletions Configuration/TCA/tx_t3sportstats_series.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<?php

if (!(defined('TYPO3') || defined('TYPO3_MODE'))) {
exit('Access denied.');
}

$tx_t3sportstats_series = [
'ctrl' => [
'title' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series',
'label' => 'name',
'label_alt' => 'label',
'label_alt_force' => 1,
'searchFields' => 'uid,name,label',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'dividers2tabs' => true,
'default_sortby' => 'ORDER BY name',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
],
'iconfile' => 'EXT:cfc_league/Resources/Public/Icons/icon_table.gif',
],
'interface' => [
'showRecordFieldList' => 'label',
],
'feInterface' => [
'fe_admin_fieldList' => 'label',
],
'columns' => [
'name' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_name',
'config' => [
'type' => 'input',
'size' => '30',
'max' => '50',
'eval' => 'required,trim',
],
],
'label' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_label',
'config' => [
'type' => 'input',
'size' => '30',
'max' => '50',
'eval' => 'required,trim',
],
],
'saison' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_saison',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'tx_cfcleague_saison',
'size' => 5,
'autoSizeMax' => 20,
'minitems' => 0,
'maxitems' => 100,
'MM' => 'tx_t3sportstats_series_scope_mm',
'MM_match_fields' => [
'tablenames' => 'tx_cfcleague_saison',
],
],
],
'competitiontag' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_tags',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'tx_t3sportstats_tags',
'size' => 5,
'autoSizeMax' => 20,
'minitems' => 0,
'maxitems' => 100,
'MM' => 'tx_t3sportstats_series_scope_mm',
'MM_match_fields' => [
'tablenames' => 'tx_t3sportstats_tags',
],
],
],
'competition' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_competition',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'tx_cfcleague_competition',
'size' => 5,
'autoSizeMax' => 20,
'minitems' => 0,
'maxitems' => 100,
'MM' => 'tx_t3sportstats_series_scope_mm',
'MM_match_fields' => [
'tablenames' => 'tx_cfcleague_competition',
],
],
],
'agegroup' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_agegroup',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [['', 0]],
'foreign_table' => 'tx_cfcleague_group',
'foreign_table_where' => 'ORDER BY tx_cfcleague_group.sorting',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
'default' => 0,
],
],
'club' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_club',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'tx_cfcleague_club',
'size' => 5,
'autoSizeMax' => 20,
'minitems' => 0,
'maxitems' => 100,
'MM' => 'tx_t3sportstats_series_scope_mm',
'MM_match_fields' => [
'tablenames' => 'tx_cfcleague_club',
],
],
],
'rules' => [
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_rules',
'description' => 'field description',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_t3sportstats_series_rule',
'foreign_field' => 'parentid',
'foreign_table_field' => 'parenttable',
'appearance' => [
'showSynchronizationLink' => true,
'showAllLocalizationLink' => true,
'showPossibleLocalizationRecords' => true,
],
],
],
'results' => [
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_results',
'description' => 'All results for this series',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_t3sportstats_series_result',
'foreign_field' => 'parentid',
'foreign_table_field' => 'parenttable',
'appearance' => [
'showNewRecordLink' => false,
],
],
],
],
'types' => [
'0' => [
'showitem' => 'hidden,name,label,saison,competitiontag,competition,agegroup,club,
--div--;LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_rules,rules,
--div--;LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_results,results
',
],
],
'palettes' => [
'1' => [
'showitem' => '',
],
],
];

if (\Sys25\RnBase\Utility\TYPO3::isTYPO104OrHigher()) {
unset($tx_t3sportstats_series['interface']['showRecordFieldList']);
}

return $tx_t3sportstats_series;
99 changes: 99 additions & 0 deletions Configuration/TCA/tx_t3sportstats_series_result.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

if (!(defined('TYPO3') || defined('TYPO3_MODE'))) {
exit('Access denied.');
}

$tx_t3sportstats_series_result = [
'ctrl' => [
'title' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_result',
'label' => 'uid',
'label_alt' => 'club',
'label_alt_force' => 1,
'searchFields' => '',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'dividers2tabs' => true,
'hideTable' => true,
'delete' => 'deleted',
'enablecolumns' => [
],
'iconfile' => 'EXT:cfc_league/Resources/Public/Icons/icon_table.gif',
],
'interface' => [
'showRecordFieldList' => 'rulealias',
],
'feInterface' => [
'fe_admin_fieldList' => 'rulealias',
],
'columns' => [
'club' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_result_club',
'config' => [
'type' => 'group',
'allowed' => 'tx_cfcleague_club',
'readonly' => '1',
'maxitems' => 1,
'size' => '1',
],
],
'quantity' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_result_quantity',
'config' => [
'type' => 'input',
'size' => '10',
'readonly' => '1',
],
],
'firstmatch' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_result_firstmatch',
'config' => [
'type' => 'group',
'allowed' => 'tx_cfcleague_games',
'readonly' => '1',
'maxitems' => 1,
'size' => '1',
],
],
'lastmatch' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_result_lastmatch',
'config' => [
'type' => 'group',
'allowed' => 'tx_cfcleague_games',
'readonly' => '1',
'maxitems' => 1,
'size' => '1',
],
],
'parentid' => [
'type' => 'passthrough'
],
'parenttable' => [
'type' => 'passthrough'
],
'uniquekey' => [
'type' => 'passthrough'
],
],
'types' => [
'0' => [
'showitem' => 'club,quantity,firstmatch,lastmatch',
],
],
'palettes' => [
'1' => [
'showitem' => '',
],
],
];

if (\Sys25\RnBase\Utility\TYPO3::isTYPO104OrHigher()) {
unset($tx_t3sportstats_series_result['interface']['showRecordFieldList']);
}

return $tx_t3sportstats_series_result;
68 changes: 68 additions & 0 deletions Configuration/TCA/tx_t3sportstats_series_rule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

if (!(defined('TYPO3') || defined('TYPO3_MODE'))) {
exit('Access denied.');
}

$tx_t3sportstats_series_rule = [
'ctrl' => [
'title' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_rule',
'label' => 'rulealias',
'searchFields' => 'rulealias',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'dividers2tabs' => true,
'hideTable' => true,
'delete' => 'deleted',
'enablecolumns' => [
],
'iconfile' => 'EXT:cfc_league/Resources/Public/Icons/icon_table.gif',
],
'interface' => [
'showRecordFieldList' => 'rulealias',
],
'feInterface' => [
'fe_admin_fieldList' => 'rulealias',
],
'columns' => [
'rulealias' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_rule_alias',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'itemsProcFunc' => System25\T3sports\Series\SeriesRuleProvider::class.'->getRules4Tca',
'size' => 1,
'minitems' => 1,
'maxitems' => 1,
],
],
'config' => [
'exclude' => 1,
'label' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db.xlf:tx_t3sportstats_series_rule_config',
'config' => [
'type' => 'text',
'cols' => '30',
'rows' => '5',
],
],

],
'types' => [
'0' => [
'showitem' => 'rulealias,config',
],
],
'palettes' => [
'1' => [
'showitem' => '',
],
],
];

if (\Sys25\RnBase\Utility\TYPO3::isTYPO104OrHigher()) {
unset($tx_t3sportstats_series_rule['interface']['showRecordFieldList']);
}

return $tx_t3sportstats_series_rule;
15 changes: 15 additions & 0 deletions Documentation/capital/series.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Serien

Es sollen Serien ermittelt werden. Also zum Beispiel wollen wir die längste Sieges- oder Niederlagenserie eines Vereins finden. Wir wollen also wissen, welche aufeinanderfolgenden Spiele ein oder mehrere gemeinsame Kriterien erfüllen.

Im ersten Schritt legt man einen Datensatz vom Typ **Serie** an. Hier legt man zunächst fest, welche Spiele für die Serie ausgewertet werden sollen. Felder, die leer gelassen werden, schränken die Suche nicht ein. Wenn man also bspw. keine Saisondatensätze auswählt, dann wird über alle Spieljahre gesucht.

Man muss nun eine Altersklasse aufwählen und einen oder mehrere Vereine auswählen. Die Serien werden dann für die Teams in der gewählten Alterklasse ermittelt. Will man für mehrere Altersklassen Serien ermitteln, dann muss man auch mehrere Serien erstellen.

Im Tab **Regeln** kann man eine oder mehrere der verfügbaren Regeln konfigurieren.

Ist die Serie gespeichert, kann man mit der UID die Suche starten. Dafür muss das Command **t3sports:stats:calculate-series** ausgeführt werden:

```bash
$ ./bin/typo3 t3sports:stats:calculate-series --uid=4
```
203 changes: 118 additions & 85 deletions Resources/Private/Language/de.locallang_db.xlf
Original file line number Diff line number Diff line change
@@ -1,88 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" data="2023-02-11T21-59-00" product-name="zsb">
<header/>
<body>
<trans-unit id="plugin.t3sportstats.label" xml:space="preserve">
<source>T3sports: Statistics</source>
<target>T3sports: Statistiken</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.description" xml:space="preserve">
<source>Shows extensive statistics of players, trainers and referees</source>
<target>Zeigt umfangreiche Statistiken von Spielern, Trainern and Schiedsrichtern</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.tab.common" xml:space="preserve">
<source>Common</source>
<target/>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.tab.TSSetup" xml:space="preserve">
<source>TS-Setup</source>
<target/>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.tssetup" xml:space="preserve">
<source>plugin.tx_t3sportstats.</source>
<target/>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.action" xml:space="preserve">
<source>View</source>
<target/>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.reporttype" xml:space="preserve">
<source>Report Type</source>
<target>Auswertung</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.highlightteam" xml:space="preserve">
<source>Highlight team players</source>
<target>Team Spieler hervorheben</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.action.playerstats" xml:space="preserve">
<source>Player statistics</source>
<target>Spielerstatistik</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.action.coachstats" xml:space="preserve">
<source>Coach statistics</source>
<target>Trainerstatistik</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.action.refereestats" xml:space="preserve">
<source>Referee statistics</source>
<target>Schiedsrichterstatistik</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.action.dbstats" xml:space="preserve">
<source>Database statistics</source>
<target>Datenbankstatistik</target>
</trans-unit>
<trans-unit id="service_t3sports_statistics_title" xml:space="preserve">
<source>Statistics service</source>
<target>Statistik Service</target>
</trans-unit>
<trans-unit id="tx_cfcleague_match_notes.type.goalfreekick" xml:space="preserve">
<source>Free kick goal</source>
<target>Freistoßtor</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.common.template" xml:space="preserve">
<source>Html-Template</source>
<target/>
</trans-unit>
<trans-unit id="plugin.t3sportstats.common.sqldebug" xml:space="preserve">
<source>Debug SQL</source>
<target/>
</trans-unit>
<trans-unit id="tx_t3sportstats_tags" xml:space="preserve">
<source>Tag</source>
<target>Tag</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_tags_name" xml:space="preserve">
<source>Name</source>
<target>Name</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_tags_label" xml:space="preserve">
<source>Label</source>
<target>Label</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_module_name" xml:space="preserve">
<source>Statistics</source>
<target>Statistik</target>
</trans-unit>
</body>
</file>
<file source-language="en" target-language="de" datatype="plaintext" original="messages" data="2023-02-11T21-59-00" product-name="zsb">
<header/>
<body>
<trans-unit id="plugin.t3sportstats.label" xml:space="preserve">
<source>T3sports: Statistics</source>
<target>T3sports: Statistiken</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.description" xml:space="preserve">
<source>Shows extensive statistics of players, trainers and referees</source>
<target>Zeigt umfangreiche Statistiken von Spielern, Trainern and Schiedsrichtern</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.tab.common" xml:space="preserve">
<source>Common</source>
<target/>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.tab.TSSetup" xml:space="preserve">
<source>TS-Setup</source>
<target/>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.tssetup" xml:space="preserve">
<source>plugin.tx_t3sportstats.</source>
<target/>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.action" xml:space="preserve">
<source>View</source>
<target/>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.reporttype" xml:space="preserve">
<source>Report Type</source>
<target>Auswertung</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.highlightteam" xml:space="preserve">
<source>Highlight team players</source>
<target>Team Spieler hervorheben</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.action.playerstats" xml:space="preserve">
<source>Player statistics</source>
<target>Spielerstatistik</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.action.coachstats" xml:space="preserve">
<source>Coach statistics</source>
<target>Trainerstatistik</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.action.refereestats" xml:space="preserve">
<source>Referee statistics</source>
<target>Schiedsrichterstatistik</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.flexform.action.dbstats" xml:space="preserve">
<source>Database statistics</source>
<target>Datenbankstatistik</target>
</trans-unit>
<trans-unit id="service_t3sports_statistics_title" xml:space="preserve">
<source>Statistics service</source>
<target>Statistik Service</target>
</trans-unit>
<trans-unit id="tx_cfcleague_match_notes.type.goalfreekick" xml:space="preserve">
<source>Free kick goal</source>
<target>Freistoßtor</target>
</trans-unit>
<trans-unit id="plugin.t3sportstats.common.template" xml:space="preserve">
<source>Html-Template</source>
<target/>
</trans-unit>
<trans-unit id="plugin.t3sportstats.common.sqldebug" xml:space="preserve">
<source>Debug SQL</source>
<target/>
</trans-unit>
<trans-unit id="tx_t3sportstats_tags" xml:space="preserve">
<source>Tag</source>
<target>Tag</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_tags_name" xml:space="preserve">
<source>Name</source>
<target>Name</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_tags_label" xml:space="preserve">
<source>Label</source>
<target>Label</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_module_name" xml:space="preserve">
<source>Statistics</source>
<target>Statistik</target>
</trans-unit>

<trans-unit id="tx_t3sportstats_series_rules" xml:space="preserve">
<source>Rules</source>
<target>Regeln</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule" xml:space="preserve">
<source>Series Rule</source>
<target>Serienregel</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule_alias" xml:space="preserve">
<source>Rule</source>
<target>Regel</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule_config" xml:space="preserve">
<source>Config (optional)</source>
<target>Konfiguration (optional)</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule.win_rule" xml:space="preserve">
<source>Won matches</source>
<target>Gewonnene Spiele</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule.lost_rule" xml:space="preserve">
<source>Lost matches</source>
<target>Verlorene Spiele</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule.not_won_rule" xml:space="preserve">
<source>Not won matches</source>
<target>Nicht gewonnene Spiele</target>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule.not_lost_rule" xml:space="preserve">
<source>Not lost matches</source>
<target>Nicht verlorene Spiele</target>
</trans-unit>
</body>
</file>
</xliff>
68 changes: 68 additions & 0 deletions Resources/Private/Language/locallang_db.xlf
Original file line number Diff line number Diff line change
@@ -63,6 +63,74 @@
<trans-unit id="tx_t3sportstats_module_name" xml:space="preserve">
<source>Statistics</source>
</trans-unit>


<trans-unit id="tx_t3sportstats_series" xml:space="preserve">
<source>Series</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_name" xml:space="preserve">
<source>Name</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_label" xml:space="preserve">
<source>Label</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_saison" xml:space="preserve">
<source>Saisons</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_club" xml:space="preserve">
<source>Clubs</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_agegroup" xml:space="preserve">
<source>Age group</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_competition" xml:space="preserve">
<source>Competitions</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rules" xml:space="preserve">
<source>Rules</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_results" xml:space="preserve">
<source>Results</source>
</trans-unit>

<trans-unit id="tx_t3sportstats_series_rule" xml:space="preserve">
<source>Series Rule</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule_alias" xml:space="preserve">
<source>Rule</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule_config" xml:space="preserve">
<source>Config (optional)</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule.win_rule" xml:space="preserve">
<source>Won matches</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule.lost_rule" xml:space="preserve">
<source>Lost matches</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule.not_won_rule" xml:space="preserve">
<source>Not won matches</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_rule.not_lost_rule" xml:space="preserve">
<source>Not lost matches</source>
</trans-unit>

<trans-unit id="tx_t3sportstats_series_result" xml:space="preserve">
<source>Series Result</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_result_club" xml:space="preserve">
<source>Club</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_result_quantity" xml:space="preserve">
<source>Number of matches</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_result_firstmatch" xml:space="preserve">
<source>First match</source>
</trans-unit>
<trans-unit id="tx_t3sportstats_series_result_lastmatch" xml:space="preserve">
<source>Last match</source>
</trans-unit>

</body>
</file>
</xliff>
7 changes: 7 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -13,6 +13,9 @@
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cfc_league_fe']['search_Match_getTableMapping_hook'][] = 'System25\T3sports\Hooks\Search->getTableMappingMatch';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cfc_league_fe']['search_Match_getJoins_hook'][] = 'System25\T3sports\Hooks\Search->getJoinsMatch';

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cfc_league']['search_Club_getTableMapping_hook'][] = 'System25\T3sports\Hooks\ClubSearch->getTableMappingMatch';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cfc_league']['search_Club_getJoins_hook'][] = 'System25\T3sports\Hooks\ClubSearch->getJoinsMatch';

// Hook for profile marker
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cfc_league_fe']['profileMarker_afterSubst'][] = 'System25\T3sports\Hooks\Marker->parseProfile';

@@ -26,6 +29,10 @@
$provider->addStatsIndexer(new \System25\T3sports\StatsIndexer\PlayerGoalStats());
$provider->addStatsIndexer(new \System25\T3sports\StatsIndexer\PlayerTimeStats());
$provider->addStatsIndexer(new \System25\T3sports\StatsIndexer\RefereeStats());

$provider = \System25\T3sports\Series\SeriesRuleProvider::getInstance();
$provider->addSeriesRule(new \System25\T3sports\Series\Rule\WinRule());
$provider->addSeriesRule(new \System25\T3sports\Series\Rule\LostRule());
}

System25\T3sports\Utility\StatsConfig::registerPlayerStatsSimple('goals', '10,11,12,13');
111 changes: 92 additions & 19 deletions ext_tables.sql
Original file line number Diff line number Diff line change
@@ -167,29 +167,102 @@ CREATE TABLE tx_t3sportstats_referees (
);

#
# Table structure for table 'tx_t3sportstats_players'
# Scope data for a match
# Table structure for table 'tx_t3sportstats_series'
#

CREATE TABLE tx_t3sportstats_series (
uid int(11) NOT NULL auto_increment,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
pid int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
hidden tinyint(4) DEFAULT '0' NOT NULL,


name varchar(255) DEFAULT '' NOT NULL,
label varchar(255) DEFAULT '' NOT NULL,
saison int(11) DEFAULT '0' NOT NULL,
agegroup int(11) DEFAULT '0' NOT NULL,
club int(11) DEFAULT '0' NOT NULL,
competition int(11) DEFAULT '0' NOT NULL,
competitiontag int(11) DEFAULT '0' NOT NULL,

rules int(11) DEFAULT '0' NOT NULL,
results int(11) DEFAULT '0' NOT NULL,
comment text NOT NULL,

PRIMARY KEY (uid),
KEY parent (pid)
);

CREATE TABLE tx_t3sportstats_series_rule (
uid int(11) NOT NULL auto_increment,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
pid int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,

parentid int(11) DEFAULT '0' NOT NULL,
parenttable varchar(50) DEFAULT '' NOT NULL,

rulealias varchar(255) DEFAULT '' NOT NULL,
config text NOT NULL,

PRIMARY KEY (uid),
KEY parent (pid)
);

#
# Table structure for table 'tx_t3sportstats_series_result'
#
CREATE TABLE tx_t3sportstats_series_result (
uid int(11) NOT NULL auto_increment,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
pid int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,

#CREATE TABLE tx_t3sportstats_matchs (
# uid int(11) NOT NULL auto_increment,
# tstamp int(11) DEFAULT '0' NOT NULL,
# crdate int(11) DEFAULT '0' NOT NULL,
parentid int(11) DEFAULT '0' NOT NULL,
parenttable varchar(50) DEFAULT '' NOT NULL,

# t3match int(11) DEFAULT '0' NOT NULL,
# competition int(11) DEFAULT '0' NOT NULL,
# saison int(11) DEFAULT '0' NOT NULL,
# group int(11) DEFAULT '0' NOT NULL,
club int(11) DEFAULT '0' NOT NULL,

# round int(11) DEFAULT '0' NOT NULL,
# round_name varchar(100) DEFAULT '' NOT NULL,
quantity int(11) DEFAULT '0' NOT NULL,
firstmatch int(11) DEFAULT '0' NOT NULL,
lastmatch int(11) DEFAULT '0' NOT NULL,
uniquekey varchar(50) DEFAULT '' NOT NULL,

# betgame int(11) DEFAULT '0' NOT NULL,
# status tinyint(4) DEFAULT '0' NOT NULL,
# teamquestions int(11) DEFAULT '0' NOT NULL,
# comment text NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);

# PRIMARY KEY (uid),
# KEY parent (pid)
#);
#
# Table structure for table 'tx_t3sportstats_series_scope_mm'
# uid_local used for series
#
CREATE TABLE tx_t3sportstats_series_scope_mm (
uid_local int(11) unsigned DEFAULT '0' NOT NULL,
uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,
tablenames varchar(50) DEFAULT '' NOT NULL,
sorting int(11) unsigned DEFAULT '0' NOT NULL,
sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL,
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);

#
# Table structure for table 'tx_t3sportstats_series_result_mm'
# uid_local used for series_result
#
CREATE TABLE tx_t3sportstats_series_result_mm (
uid_local int(11) unsigned DEFAULT '0' NOT NULL,
uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,
tablenames varchar(50) DEFAULT '' NOT NULL,
sorting int(11) unsigned DEFAULT '0' NOT NULL,
sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL,
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);

0 comments on commit a74a64f

Please sign in to comment.