<commit_before>package Billy::Controller::Transactions;
use Moose;
use namespace::autoclean;
use DateTime;

BEGIN { extends 'Catalyst::Controller'; }

sub index : Path : Args(0) {
    my ($self, $c) = @_;

    my @transactions = $c->model('DB::Transaction')->get_recent();

    $c->stash(
        template     => 'transactions/index.tt',
        transactions => [@transactions]
    );
}

sub form_create : Local : Args(0) {
    my ($self, $c) = @_;

    my @companies = $c->model('DB::Company')->get_and_sort();    
    $c->stash(
        template    => 'transactions/form.tt',
        transaction => undef,
        companies   => [@companies]
    );
}

sub form_update : Local : Args(1) {
    my ($self, $c, $id) = @_;

    my @companies = $c->model('DB::Company')->get_and_sort();
    if (my $tx = $c->model('DB::Transaction')->find($id)) {
        return $c->stash(
            template    => 'transactions/form.tt',<commit_msg>do not fetch companies unless transaction found<commit_after>package Billy::Controller::Transactions;
use Moose;
use namespace::autoclean;
use DateTime;

BEGIN { extends 'Catalyst::Controller'; }

sub index : Path : Args(0) {
    my ($self, $c) = @_;

    my @transactions = $c->model('DB::Transaction')->get_recent();

    $c->stash(
        template     => 'transactions/index.tt',
        transactions => [@transactions]
    );
}

sub form_create : Local : Args(0) {
    my ($self, $c) = @_;

    my @companies = $c->model('DB::Company')->get_and_sort();    
    $c->stash(
        template    => 'transactions/form.tt',
        transaction => undef,
        companies   => [@companies]
    );
}

sub form_update : Local : Args(1) {
    my ($self, $c, $id) = @_;

    if (my $tx = $c->model('DB::Transaction')->find($id)) {
        my @companies = $c->model('DB::Company')->get_and_sort();
        return $c->stash(
            template    => 'transactions/form.tt',
{'fraction_non_alphanumeric': 0.18947368421052632, 'fraction_numerical': 0.003157894736842105, 'mean_word_length': 2.9034907597535935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, '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': '2347670', 'n_tokens_mistral': 649, 'n_tokens_neox': 634, 'n_words': 129}