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';
26 __PACKAGE__->load_components('Helper::ResultSet');
28 use Debbugs::DB::Util qw(select_one);
30 use List::MoreUtils qw(natatime);
35 =item update_bug_status
37 $s->resultset('BugStatusCache')->
38 update_bug_status($bug->id,
44 Update the status information for a particular bug at a particular suite
48 sub update_bug_status {
49 my ($self,@args) = @_;
50 return $self->result_source->schema->storage->
52 my ($s,$dbh,$bug,$suite,$arch,$status,$modified,$asof) = @_;
53 select_one($dbh,<<'SQL',$bug,$suite,$arch,$status,$status);
54 INSERT INTO bug_status_cache AS bsc
55 (bug,suite,arch,status,modified,asof)
56 VALUES (?,?,?,?,NOW(),NOW())
57 ON CONFLICT (bug,suite,arch) DO
59 SET asof=NOW(),modified=CASE WHEN bsc.status=? THEN bsc.modified ELSE NOW() END