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::Bug;
10 Debbugs::DB::ResultSet::Bug - 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 quick_insert_bugs
36 $s->result_set('Bug')->quick_insert_bugs(@bugs);
38 Quickly insert a set of bugs (without any useful information, like subject,
39 etc). This should probably only be called when inserting bugs in the database
45 sub quick_insert_bugs {
46 my ($self,@bugs) = @_;
48 my $it = natatime 2000, @bugs;
50 while (my @b = $it->()) {
51 $self->result_source->schema->
54 $self->quick_insert_bug($b);
60 =item quick_insert_bug
62 $s->result_set('Bug')->quick_insert_bug($bug);
64 Quickly insert a single bug (called by quick_insert_bugs). You should probably
65 actually be calling C<Debbugs::DB::Load::load_bug> instead of this function.
69 sub quick_insert_bug {
71 return $self->result_source->schema->storage->
74 select_one($dbh,<<'SQL',$b);
75 INSERT INTO bug (id,subject,severity) VALUES (?,'',1)
76 ON CONFLICT (id) DO NOTHING RETURNING id;