Skip to content

Commit 7e8327c

Browse files
authored
Merge pull request #6277 from solgenomics/topic/discarded_seedlots
DB Patch: Update seedlots view
2 parents 93775fa + 25e5ab1 commit 7e8327c

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

db/00203/UpdateMaterializedPhenoviewIntercrop.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ SELECT stock.stock_id AS seedlot_id,
295295
stock.uniquename AS seedlot_name
296296
FROM stock
297297
WHERE stock.type_id = (SELECT cvterm_id from cvterm where cvterm.name = 'seedlot') AND is_obsolete = 'f'
298+
AND stock_id NOT IN (SELECT DISTINCT(stock_id) FROM stockprop WHERE type_id = (SELECT cvterm_id FROM cvterm WHERE name = 'discarded_metadata'))
298299
GROUP BY public.stock.stock_id, public.stock.uniquename;
299300
ALTER VIEW seedlots OWNER TO web_usr;
300301

db/00208/UpdateSeedlotsView.pm

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env perl
2+
3+
4+
=head1 NAME
5+
6+
UpdateSeedlotsView
7+
8+
=head1 SYNOPSIS
9+
10+
mx-run UpdateSeedlotsView [options] -H hostname -D dbname -u username [-F]
11+
12+
this is a subclass of L<CXGN::Metadata::Dbpatch>
13+
see the perldoc of parent class for more details.
14+
15+
=head1 DESCRIPTION
16+
17+
This is a test dummy patch.
18+
This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
19+
20+
=head1 AUTHOR
21+
22+
David Waring <djw64@cornell.edu>
23+
24+
=head1 COPYRIGHT & LICENSE
25+
26+
Copyright 2010 Boyce Thompson Institute for Plant Research
27+
28+
This program is free software; you can redistribute it and/or modify
29+
it under the same terms as Perl itself.
30+
31+
=cut
32+
33+
34+
package UpdateSeedlotsView;
35+
36+
use Moose;
37+
extends 'CXGN::Metadata::Dbpatch';
38+
39+
40+
has '+description' => ( default => <<'' );
41+
This updates the seedlots view to filter out discarded seedlots
42+
43+
has '+prereq' => (
44+
default => sub {
45+
[],
46+
},
47+
);
48+
49+
sub patch {
50+
my $self=shift;
51+
52+
print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
53+
54+
print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
55+
56+
print STDOUT "\nExecuting the SQL commands.\n";
57+
58+
59+
$self->dbh()->do( <<EOSQL);
60+
--do your SQL here
61+
--
62+
DROP VIEW IF EXISTS public.seedlots;
63+
CREATE VIEW public.seedlots AS
64+
SELECT stock.stock_id AS seedlot_id,
65+
stock.uniquename AS seedlot_name
66+
FROM stock
67+
WHERE stock.type_id = (SELECT cvterm_id from cvterm where cvterm.name = 'seedlot') AND is_obsolete = 'f'
68+
AND stock_id NOT IN (SELECT DISTINCT(stock_id) FROM stockprop WHERE type_id = (SELECT cvterm_id FROM cvterm WHERE name = 'discarded_metadata'))
69+
GROUP BY public.stock.stock_id, public.stock.uniquename;
70+
ALTER VIEW seedlots OWNER TO web_usr;
71+
72+
EOSQL
73+
74+
print "You're done!\n";
75+
}
76+
77+
78+
####
79+
1; #
80+
####

0 commit comments

Comments
 (0)