<commit_before>package MediaWords::Model::DBIS;
use Modern::Perl "2012";
use MediaWords::CommonLibs;

# custom DBIx::Simple::MediaWords based model for mediawords

use strict;

use DBIx::Simple::MediaWords;

use MediaWords::DB;

use base qw(Catalyst::Model);

sub new
{
    my $self = shift->SUPER::new( @_ );

    my @info = @{ $self->{ connect_info } || [] };

    # TODO replace this with  MediaWords::DB::connect_to_db();
    $self->{ dbis } = DBIx::Simple::MediaWords->connect( MediaWords::DB::connect_info )
      or die DBIx::Simple::MediaWords->error;

    $self->{ dbis }->dbh->{ RaiseError } = 1;

    return $self;
}

sub dbis
{

    return $_[ 0 ]->{ dbis };
}

1;<commit_msg>create new database connection for each connection to avoid connections stuck in a bad transaction<commit_after>package MediaWords::Model::DBIS;
use Modern::Perl "2012";
use MediaWords::CommonLibs;

# custom DBIx::Simple::MediaWords based model for mediawords

use strict;

use DBIx::Simple::MediaWords;

use MediaWords::DB;

use base qw(Catalyst::Model);

sub new
{
    my $self = shift->SUPER::new( @_ );

    my @info = @{ $self->{ connect_info } || [] };

    return $self;
}

sub dbis
{

    # TODO replace this with  MediaWords::DB::connect_to_db();
    my $db = DBIx::Simple::MediaWords->connect( MediaWords::DB::connect_info )
      or die DBIx::Simple::MediaWords->error;

    $db->dbh->{ RaiseError } = 1;

    return $db;
}

1;
{'fraction_non_alphanumeric': 0.15988779803646563, 'fraction_numerical': 0.0091164095371669, 'mean_word_length': 4.189090909090909, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '4094174', 'n_tokens_mistral': 535, 'n_tokens_neox': 494, 'n_words': 122}