<commit_before><?php

namespace CultuurNet\UDB3\Storage;

use Doctrine\DBAL\Connection;

/**
 * Class DBALPurgeService
 * @package CultuurNet\UDB3\Storage
 */
class DBALPurgeService implements PurgeServiceInterface
{
    /**
     * @var Connection
     */
    private $connection;

    /**
     * @var string
     */
    private $tableName;

    /**
     * DBALPurgeService constructor.
     * @param Connection $connection
     * @param string $tableName
     */
    public function __construct(
        $connection,
        $tableName
    ) {
        $this->connection = $connection;

        $this->tableName = $tableName;
    }

    public function purgeAll()
    {
        $queryBuilder = $this->connection->createQueryBuilder();

        $queryBuilder->delete($this->tableName);
        $queryBuilder->execute();
    }
}<commit_msg>III-633 Also reset the auto_increment to 1.<commit_after><?php

namespace CultuurNet\UDB3\Storage;

use Doctrine\DBAL\Connection;

/**
 * Class DBALPurgeService
 * @package CultuurNet\UDB3\Storage
 */
class DBALPurgeService implements PurgeServiceInterface
{
    /**
     * @var Connection
     */
    private $connection;

    /**
     * @var string
     */
    private $tableName;

    /**
     * DBALPurgeService constructor.
     * @param Connection $connection
     * @param string $tableName
     */
    public function __construct(
        $connection,
        $tableName
    ) {
        $this->connection = $connection;

        $this->tableName = $tableName;
    }

    public function purgeAll()
    {
        $this->delete();

        $this->resetAutoIncrement();
    }

    private function delete()
    {
        $queryBuilder = $this->connection->createQueryBuilder();

        $queryBuilder->delete($this->tableName);
        $queryBuilder->execute();
    }

    private function resetAutoIncrement()
    {
        $sql = 'ALTER TABLE ' . $this->tableName . ' auto_increment = 1';
        $this->connection->exec($sql);
    }
}
{'fraction_non_alphanumeric': 0.12525252525252525, 'fraction_numerical': 0.004545454545454545, 'mean_word_length': 2.392123287671233, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, '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': '797553', 'n_tokens_mistral': 601, 'n_tokens_neox': 576, 'n_words': 111}