Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing the refresh_matviews script to be run synchronously. #4632

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/CXGN/BrAPI/v2/Germplasm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ sub store {
}

my $bs = CXGN::BreederSearch->new( { dbh=>$dbh, dbname=>$c->config->{dbname}, } );
my $refresh = $bs->refresh_matviews($c->config->{dbhost}, $c->config->{dbname}, $c->config->{dbuser}, $c->config->{dbpass}, 'stockprop', 'concurrent', $c->config->{basepath});

my $refresh = $bs->refresh_matviews($c->config->{dbhost}, $c->config->{dbname}, $c->config->{dbuser}, $c->config->{dbpass}, 'stockprop', 'concurrent', $c->config->{basepath}, 0);

#retrieve saved items
my @data = _simple_search($self,undef,$accession_list);
Expand Down Expand Up @@ -1017,7 +1018,7 @@ sub update {

#update matviews
my $bs = CXGN::BreederSearch->new( { dbh=>$dbh, dbname=>$c->config->{dbname}, } );
my $refresh = $bs->refresh_matviews($c->config->{dbhost}, $c->config->{dbname}, $c->config->{dbuser}, $c->config->{dbpass}, 'stockprop', 'concurrent', $c->config->{basepath});
my $refresh = $bs->refresh_matviews($c->config->{dbhost}, $c->config->{dbname}, $c->config->{dbuser}, $c->config->{dbpass}, 'stockprop', 'concurrent', $c->config->{basepath}, 0);

#retrieve updated item
my @result = _simple_search($self,[$germplasm_id]);
Expand Down
26 changes: 20 additions & 6 deletions lib/CXGN/BreederSearch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ sub refresh_matviews {
my $materialized_view = shift || 'fullview'; #Can be 'fullview' or 'stockprop'
my $refresh_type = shift || 'concurrent';
my $basepath = shift;
my $async = shift;

if (!defined($async)) {
$async = 1;
}

my $refresh_finished = 0;
my $async_refresh;

Expand All @@ -354,14 +360,22 @@ sub refresh_matviews {
}
else {
try {
my $refresh_command = "perl $basepath/bin/refresh_matviews.pl -H $dbhost -D $dbname -U $dbuser -P $dbpass -m $materialized_view";
$async_refresh = CXGN::Tools::Run->new();
if ($refresh_type eq 'concurrent') {
print STDERR "Using CXGN::Tools::Run to run perl bin/refresh_matviews.pl -H $dbhost -D $dbname -U $dbuser -P $dbpass -m $materialized_view -c\n";
$async_refresh = CXGN::Tools::Run->new();
$async_refresh->run_async("perl $basepath/bin/refresh_matviews.pl -H $dbhost -D $dbname -U $dbuser -P $dbpass -m $materialized_view -c");
print STDERR "Using CXGN::Tools::Run to ".($async ? "asynchronously" : "synchronously")." run $refresh_command -c\n";
if ($async) {
$async_refresh->run_async($refresh_command." -c");
} else {
$async_refresh->run($refresh_command." -c");
}
} else {
print STDERR "Using CXGN::Tools::Run to run perl bin/refresh_matviews.pl -H $dbhost -D $dbname -U $dbuser -P $dbpass -m $materialized_view\n";
$async_refresh = CXGN::Tools::Run->new();
$async_refresh->run_async("perl $basepath/bin/refresh_matviews.pl -H $dbhost -D $dbname -U $dbuser -P $dbpass -m $materialized_view");
print STDERR "Using CXGN::Tools::Run to ".($async ? "asynchronously" : "synchronously")." run $refresh_command\n";
if ($async) {
$async_refresh->run_async($refresh_command);
} else {
$async_refresh->run($refresh_command);
}
}

for (my $i = 1; $i < 10; $i++) {
Expand Down