]> git.donarmstrong.com Git - debbugs.git/blob - lib/Debbugs/DB/ResultSet/BugStatusCache.pm
Debbugs::DB::Util is now a component of Debbugs::DB
[debbugs.git] / lib / Debbugs / DB / ResultSet / BugStatusCache.pm
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>.
5 use utf8;
6 package Debbugs::DB::ResultSet::BugStatusCache;
7
8 =head1 NAME
9
10 Debbugs::DB::ResultSet::BugStatusCache - Bug result set operations
11
12 =head1 SYNOPSIS
13
14
15
16 =head1 DESCRIPTION
17
18
19
20 =cut
21
22 use strict;
23 use warnings;
24
25 use base 'DBIx::Class::ResultSet';
26
27 use List::AllUtils qw(natatime);
28
29
30 =over
31
32 =item update_bug_status
33
34         $s->resultset('BugStatusCache')->
35             update_bug_status($bug->id,
36                               $suite->{id},
37                               undef,
38                               $presence,
39                               );
40
41 Update the status information for a particular bug at a particular suite
42
43 =cut
44
45 sub update_bug_status {
46     my ($self,$bug,$suite,$arch,$status,$modified,$asof) = @_;
47     return $self->result_source->schema->
48         select_one(<<'SQL',$bug,$suite,$arch,$status,$status);
49 INSERT INTO bug_status_cache AS bsc
50 (bug,suite,arch,status,modified,asof)
51 VALUES (?,?,?,?,NOW(),NOW())
52 ON CONFLICT (bug,COALESCE(suite,0),COALESCE(arch,0)) DO
53 UPDATE
54  SET asof=NOW(),modified=CASE WHEN bsc.status=? THEN bsc.modified ELSE NOW() END
55 RETURNING status;
56 SQL
57 }
58
59
60 =back
61
62 =cut
63
64
65 1;
66
67 __END__