<commit_before>=head1 NAME

Unison::run_history -- API to the Unison run_history table

S<$Id: run_history.pm,v 1.7 2005/04/04 16:42:31 rkh Exp $>

=head1 SYNOPSIS

 use Unison;
 use Unison::run_history;
 my $u = new Unison(...);

=head1 DESCRIPTION

B<Unison::blat> provides BLAT-related methods to the B<Unison::>
namespace.

=cut


package Unison;
use CBT::debug;
CBT::debug::identify_file() if ($CBT::debug::trace_uses);

use strict;
use warnings;


=pod

=head1 ROUTINES AND METHODS

=over

=cut


######################################################################
## upd_run_history

=pod

=item B<< $u->upd_run_history( C<pseq_id>, C<params_id>, C<porigin_id>, C<pmodelset_id>, failed ) >>

=cut

sub upd_run_history(@) {
  my $u = shift;
  my ($q,$p,$o,$m,$f) = @_;
  $f ||= 'FALSE';
  return $u->selectrow_array("select upd_run_history(?,?,?,?,?)"
							 ,undef, $q,$p,$o,$m,$f);
}


######################################################################
## upd_run_histories

=pod

=item B<< $u->upd_run_histories( C<pseq_id>, C<params_id>, C<[porigin_ids]>, C<[pmodelset_ids]>  ) >>

=cut

sub upd_run_histories($$$$$) {
  my ($u,$pseq_id,$params_id,$O,$M,$f) = @_;
  my (@O) = defined $O ? ref $O ? @$O : ($O) : (undef);
  my (@M) = defined $M ? ref $M ? @$M : ($M) : (undef);
  my $z;
  foreach my $o (@O) {
	foreach my $m (@M) {
	  $z = $u->upd_run_history($pseq_id,$params_id,$o,$m,$f);
	}
  }
  return $z;
}



######################################################################
## already_ran

=pod

=item B<< $u->already_ran( C<pseq_id>, C<params_id>, C<[porigin_ids]>, C<[pmodelset_ids]> ) >>

=cut

sub already_ran ($$$$$) {
  my ($u,$pseq_id,$params_id,$O,$M) = @_;
  my (@O) = defined $O ? ref $O ? @$O : ($O) : (undef);
  my (@M) = defined $M ? ref $M ? @$M : ($M) : (undef);

  foreach my $o (@O) {
	foreach my $m (@M) {
	  if ($u->get_run_timestamp($pseq_id,$params_id,$o,$m)) {
		return 1;
	  }
	}
  }
  return 0;
}



######################################################################
##  get_run_timestamp

=pod

=item B<< $u->get_run_timestamp( C<pseq_id>, C<params_id>, C<porigin_id>, C<pmodelset_id> ) >>

=cut

sub get_run_timestamp(@) {
  my $u = shift;
  return $u->selectrow_array("select get_run_timestamp(?,?,?,?)",undef,@_);
}






=pod

=back

=head1 BUGS
<commit_msg>* added get_current_params_id_by_pftype<commit_after>=head1 NAME

Unison::run_history -- API to the Unison run_history table

S<$Id: run_history.pm,v 1.8 2005/05/11 21:53:41 rkh Exp $>

=head1 SYNOPSIS

 use Unison;
 use Unison::run_history;
 my $u = new Unison(...);

=head1 DESCRIPTION

B<Unison::blat> provides BLAT-related methods to the B<Unison::>
namespace.

=cut


package Unison;
use CBT::debug;
CBT::debug::identify_file() if ($CBT::debug::trace_uses);

use strict;
use warnings;


=pod

=head1 ROUTINES AND METHODS

=over

=cut


######################################################################
## upd_run_history

=pod

=item B<< $u->upd_run_history( C<pseq_id>, C<params_id>, C<porigin_id>, C<pmodelset_id>, failed ) >>

=cut

sub upd_run_history(@) {
  my $u = shift;
  my ($q,$p,$o,$m,$f) = @_;
  $f ||= 'FALSE';
  return $u->selectrow_array("select upd_run_history(?,?,?,?,?)"
							 ,undef, $q,$p,$o,$m,$f);
}


######################################################################
## upd_run_histories

=pod

=item B<< $u->upd_run_histories( C<pseq_id>, C<params_id>, C<[porigin_ids]>, C<[pmodelset_ids]>  ) >>

=cut

sub upd_run_histories($$$$$) {
  my ($u,$pseq_id,$params_id,$O,$M,$f) = @_;
  my (@O) = defined $O ? ref $O ? @$O : ($O) : (undef);
  my (@M) = defined $M ? ref $M ? @$M : ($M) : (undef);
  my $z;
  foreach my $o (@O) {
	foreach my $m (@M) {
	  $z = $u->upd_run_history($pseq_id,$params_id,$o,$m,$f);
	}
  }
  return $z;
}



######################################################################
## already_ran

=pod

=item B<< $u->already_ran( C<pseq_id>, C<params_id>, C<[porigin_ids]>, C<[pmodelset_ids]> ) >>

=cut

sub already_ran ($$$$$) {
  my ($u,$pseq_id,$params_id,$O,$M) = @_;
  my (@O) = defined $O ? ref $O ? @$O : ($O) : (undef);
  my (@M) = defined $M ? ref $M ? @$M : ($M) : (undef);

  foreach my $o (@O) {
	foreach my $m (@M) {
	  if ($u->get_run_timestamp($pseq_id,$params_id,$o,$m)) {
		return 1;
	  }
	}
  }
  return 0;
}



######################################################################
##  get_run_timestamp

=pod

=item B<< $u->get_run_timestamp( C<pseq_id>, C<params_id>, C<porigin_id>, C<pmodelset_id> ) >>

=cut

sub get_run_timestamp(@) {
  my $u = shift;
  return $u->selectrow_array("select get_run_timestamp(?,?,?,?)",undef,@_);
}


######################################################################
##  get_current_params_id_by_pftype

=pod

=item B<< $u->get_current_params_id_by_pftype( C<pseq_id>, C<pftype> ) >>

Identifies the most current params_id by pftype (NOT pftype_id!) based
on the run history for the specified sequence.

=cut

sub get_current_params_id_by_pftype(@) {
  my $u = shift;
  my $a = $u->selectrow_array(<<EOSQL,undef,@_);
SELECT	RH.params_id
  FROM	run_history RH
  JOIN	params P  ON rh.params_id=P.params_id
 WHERE	RH.pseq_id=?
   AND  P.pftype_id=pftype_id(?)
 ORDER	BY params_id DESC
 LIMIT  1;
EOSQL
  return $a;
}




=pod

=back

=head1 BUGS

{'fraction_non_alphanumeric': 0.3012869038607116, 'fraction_numerical': 0.008894776684330053, 'mean_word_length': 4.905027932960894, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 79, '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': '636086', 'n_tokens_mistral': 2257, 'n_tokens_neox': 2113, 'n_words': 447}