1 # This module is part of debbugs, and is released
2 # under the terms of the GPL version 2, or any later version. See the
3 # file README and COPYING for more information.
4 # Copyright 2017 by Don Armstrong <don@donarmstrong.com>.
6 package Debbugs::DB::ResultSet::BugStatusCache;
10 Debbugs::DB::ResultSet::BugStatusCache - Bug result set operations
25 use base 'DBIx::Class::ResultSet';
27 use Debbugs::DB::Util qw(select_one);
29 use List::AllUtils qw(natatime);
34 =item update_bug_status
36 $s->resultset('BugStatusCache')->
37 update_bug_status($bug->id,
43 Update the status information for a particular bug at a particular suite
47 sub update_bug_status {
48 my ($self,@args) = @_;
49 return $self->result_source->schema->storage->
51 my ($s,$dbh,$bug,$suite,$arch,$status,$modified,$asof) = @_;
52 select_one($dbh,<<'SQL',$bug,$suite,$arch,$status,$status);
53 INSERT INTO bug_status_cache AS bsc
54 (bug,suite,arch,status,modified,asof)
55 VALUES (?,?,?,?,NOW(),NOW())
56 ON CONFLICT (bug,COALESCE(suite,0),COALESCE(arch,0)) DO
58 SET asof=NOW(),modified=CASE WHEN bsc.status=? THEN bsc.modified ELSE NOW() END