X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FDB%2FResultSet%2FBugStatusCache.pm;fp=Debbugs%2FDB%2FResultSet%2FBugStatusCache.pm;h=d47f467829bef926c19320299d9c4ab8ef957228;hb=53c435119200ab9b1c2538a96b8374c51a078855;hp=0000000000000000000000000000000000000000;hpb=0e8f07fda6e40b5967d9c6b28b3200db22766343;p=debbugs.git diff --git a/Debbugs/DB/ResultSet/BugStatusCache.pm b/Debbugs/DB/ResultSet/BugStatusCache.pm new file mode 100644 index 0000000..d47f467 --- /dev/null +++ b/Debbugs/DB/ResultSet/BugStatusCache.pm @@ -0,0 +1,74 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later version. See the +# file README and COPYING for more information. +# Copyright 2017 by Don Armstrong . +use utf8; +package Debbugs::DB::ResultSet::BugStatusCache; + +=head1 NAME + +Debbugs::DB::ResultSet::BugStatusCache - Bug result set operations + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + + + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::ResultSet'; + +use Debbugs::DB::Util qw(select_one); + +use List::MoreUtils qw(natatime); + + +=over + +=item update_bug_status + + $s->resultset('BugStatusCache')-> + update_bug_status($bug->id, + $suite->{id}, + undef, + $presence, + ); + +Update the status information for a particular bug at a particular suite + +=cut + +sub update_bug_status { + my ($self,@args) = @_; + return $self->result_source->schema->storage-> + dbh_do(sub { + my ($s,$dbh,$bug,$suite,$arch,$status,$modified,$asof) = @_; + select_one($dbh,<<'SQL',$bug,$suite,$arch,$status,$status); +INSERT INTO bug_status_cache AS bsc +(bug,suite,arch,status,modified,asof) +VALUES (?,?,?,?,NOW(),NOW()) +ON CONFLICT (bug,COALESCE(suite,0),COALESCE(arch,0)) DO +UPDATE + SET asof=NOW(),modified=CASE WHEN bsc.status=? THEN bsc.modified ELSE NOW() END +RETURNING status; +SQL + }, + @args + ); +} + + +=back + +=cut + + +1; + +__END__