Rename aggregate members to constituents

This commit is contained in:
Eelco Dolstra 2013-08-15 02:33:10 +02:00
parent e4141afcc9
commit 1776d9118f
7 changed files with 67 additions and 59 deletions

View file

@ -160,12 +160,12 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc,
} }
xmlAttrs["maintainers"] = maintainers; xmlAttrs["maintainers"] = maintainers;
/* If this is an aggregate, then get its members. */ /* If this is an aggregate, then get its constituents. */
Bindings::iterator a = v.attrs->find(state.symbols.create("_hydraAggregate")); Bindings::iterator a = v.attrs->find(state.symbols.create("_hydraAggregate"));
if (a != v.attrs->end() && state.forceBool(*a->value)) { if (a != v.attrs->end() && state.forceBool(*a->value)) {
Bindings::iterator a = v.attrs->find(state.symbols.create("members")); Bindings::iterator a = v.attrs->find(state.symbols.create("constituents"));
if (a == v.attrs->end()) if (a == v.attrs->end())
throw EvalError("derivation must have a members attribute"); throw EvalError("derivation must have a constituents attribute");
PathSet context; PathSet context;
state.coerceToString(*a->value, context, true, false); state.coerceToString(*a->value, context, true, false);
PathSet drvs; PathSet drvs;
@ -174,7 +174,7 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc,
size_t index = i->find("!", 1); size_t index = i->find("!", 1);
drvs.insert(string(*i, index + 1)); drvs.insert(string(*i, index + 1));
} }
xmlAttrs["members"] = concatStringsSep(" ", drvs); xmlAttrs["constituents"] = concatStringsSep(" ", drvs);
} }
/* Register the derivation as a GC root. !!! This /* Register the derivation as a GC root. !!! This

View file

@ -1,12 +1,12 @@
use utf8; use utf8;
package Hydra::Schema::AggregateMembers; package Hydra::Schema::AggregateConstituents;
# Created by DBIx::Class::Schema::Loader # Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE # DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME =head1 NAME
Hydra::Schema::AggregateMembers Hydra::Schema::AggregateConstituents
=cut =cut
@ -27,11 +27,11 @@ use base 'DBIx::Class::Core';
__PACKAGE__->load_components("+Hydra::Component::ToJSON"); __PACKAGE__->load_components("+Hydra::Component::ToJSON");
=head1 TABLE: C<AggregateMembers> =head1 TABLE: C<AggregateConstituents>
=cut =cut
__PACKAGE__->table("AggregateMembers"); __PACKAGE__->table("AggregateConstituents");
=head1 ACCESSORS =head1 ACCESSORS
@ -41,7 +41,7 @@ __PACKAGE__->table("AggregateMembers");
is_foreign_key: 1 is_foreign_key: 1
is_nullable: 0 is_nullable: 0
=head2 member =head2 constituent
data_type: 'integer' data_type: 'integer'
is_foreign_key: 1 is_foreign_key: 1
@ -52,7 +52,7 @@ __PACKAGE__->table("AggregateMembers");
__PACKAGE__->add_columns( __PACKAGE__->add_columns(
"aggregate", "aggregate",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"member", "constituent",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
); );
@ -62,13 +62,13 @@ __PACKAGE__->add_columns(
=item * L</aggregate> =item * L</aggregate>
=item * L</member> =item * L</constituent>
=back =back
=cut =cut
__PACKAGE__->set_primary_key("aggregate", "member"); __PACKAGE__->set_primary_key("aggregate", "constituent");
=head1 RELATIONS =head1 RELATIONS
@ -87,7 +87,7 @@ __PACKAGE__->belongs_to(
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
); );
=head2 member =head2 constituent
Type: belongs_to Type: belongs_to
@ -96,15 +96,15 @@ Related object: L<Hydra::Schema::Builds>
=cut =cut
__PACKAGE__->belongs_to( __PACKAGE__->belongs_to(
"member", "constituent",
"Hydra::Schema::Builds", "Hydra::Schema::Builds",
{ id => "member" }, { id => "constituent" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
); );
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-08-13 22:17:52 # Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-08-15 00:20:01
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jHJtO2baXiprv0OcWCLZ+w # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TLNenyPLIWw2gWsOVhplZw
# You can replace this text with custom code or comments, and it will be preserved on regeneration # You can replace this text with custom code or comments, and it will be preserved on regeneration

View file

@ -288,33 +288,33 @@ __PACKAGE__->set_primary_key("id");
=head1 RELATIONS =head1 RELATIONS
=head2 aggregatemembers_aggregates =head2 aggregateconstituents_aggregates
Type: has_many Type: has_many
Related object: L<Hydra::Schema::AggregateMembers> Related object: L<Hydra::Schema::AggregateConstituents>
=cut =cut
__PACKAGE__->has_many( __PACKAGE__->has_many(
"aggregatemembers_aggregates", "aggregateconstituents_aggregates",
"Hydra::Schema::AggregateMembers", "Hydra::Schema::AggregateConstituents",
{ "foreign.aggregate" => "self.id" }, { "foreign.aggregate" => "self.id" },
undef, undef,
); );
=head2 aggregatemembers_members =head2 aggregateconstituents_constituents
Type: has_many Type: has_many
Related object: L<Hydra::Schema::AggregateMembers> Related object: L<Hydra::Schema::AggregateConstituents>
=cut =cut
__PACKAGE__->has_many( __PACKAGE__->has_many(
"aggregatemembers_members", "aggregateconstituents_constituents",
"Hydra::Schema::AggregateMembers", "Hydra::Schema::AggregateConstituents",
{ "foreign.member" => "self.id" }, { "foreign.constituent" => "self.id" },
undef, undef,
); );
@ -502,25 +502,33 @@ __PACKAGE__->has_many(
Type: many_to_many Type: many_to_many
Composing rels: L</aggregatemembers_members> -> aggregate Composing rels: L</aggregateconstituents_constituents> -> aggregate
=cut =cut
__PACKAGE__->many_to_many("aggregates", "aggregatemembers_members", "aggregate"); __PACKAGE__->many_to_many(
"aggregates",
"aggregateconstituents_constituents",
"aggregate",
);
=head2 members =head2 constituents
Type: many_to_many Type: many_to_many
Composing rels: L</aggregatemembers_members> -> member Composing rels: L</aggregateconstituents_constituents> -> constituent
=cut =cut
__PACKAGE__->many_to_many("members", "aggregatemembers_members", "member"); __PACKAGE__->many_to_many(
"constituents",
"aggregateconstituents_constituents",
"constituent",
);
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-08-13 22:17:52 # Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-08-15 00:20:01
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9jqsol/evbHYjusT09hLtw # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:U1j/qm0vslb6Jvgu5mGMtw
__PACKAGE__->has_many( __PACKAGE__->has_many(
"dependents", "dependents",
@ -552,7 +560,7 @@ __PACKAGE__->has_many(
__PACKAGE__->many_to_many("jobsetevals", "jobsetevalmembers", "eval"); __PACKAGE__->many_to_many("jobsetevals", "jobsetevalmembers", "eval");
__PACKAGE__->many_to_many("members_", "aggregatemembers_aggregates", "member"); __PACKAGE__->many_to_many("constituents_", "aggregateconstituents_aggregates", "constituent");
sub makeSource { sub makeSource {
my ($name, $query) = @_; my ($name, $query) = @_;

View file

@ -7,7 +7,7 @@
[% project = build.project %] [% project = build.project %]
[% jobset = build.jobset %] [% jobset = build.jobset %]
[% job = build.job %] [% job = build.job %]
[% isAggregate = build.members_ ? 1 : 0 %] [% isAggregate = build.constituents_ ? 1 : 0 %]
[% BLOCK renderOutputs %] [% BLOCK renderOutputs %]
[% start=1; FOREACH output IN outputs %] [% start=1; FOREACH output IN outputs %]
@ -119,21 +119,21 @@
<td> <td>
[% INCLUDE renderStatus build=build icon=0 %] [% INCLUDE renderStatus build=build icon=0 %]
[% IF isAggregate; [% IF isAggregate;
nrMembers = 0; nrConstituents = 0;
nrFinished = 0; nrFinished = 0;
nrFailedMembers = 0; nrFailedConstituents = 0;
FOREACH b IN build.members_; FOREACH b IN build.constituents_;
nrMembers = nrMembers + 1; nrConstituents = nrConstituents + 1;
IF b.finished; nrFinished = nrFinished + 1; END; IF b.finished; nrFinished = nrFinished + 1; END;
IF b.finished && b.buildstatus != 0; nrFailedMembers = nrFailedMembers + 1; END; IF b.finished && b.buildstatus != 0; nrFailedConstituents = nrFailedConstituents + 1; END;
END; END;
%]; %];
[%+ IF nrFinished == 0 && nrFailedMembers == 0 %] [%+ IF nrFinished == nrMembers && nrFailedConstituents == 0 %]
all [% nrMembers %] constituent builds succeeded all [% nrConstituents %] constituent builds succeeded
[% ELSE %] [% ELSE %]
[% nrFailedMembers %] out of [% nrMembers %] constituent builds failed [% nrFailedConstituents %] out of [% nrConstituents %] constituent builds failed
[% IF nrFinished < nrMembers %] [% IF nrFinished < nrConstituents %]
([% nrMembers - nrFinished %] still pending) ([% nrConstituents - nrFinished %] still pending)
[% END %] [% END %]
[% END %] [% END %]
[% END %] [% END %]
@ -280,7 +280,7 @@
<p>This build is an aggregate of the following builds:</p> <p>This build is an aggregate of the following builds:</p>
[% INCLUDE renderBuildList builds=build.members_ %] [% INCLUDE renderBuildList builds=build.constituents_ %]
</div> </div>

View file

@ -183,16 +183,16 @@ sub checkJobsetWrapped {
$drvPathToId{$x->{drvPath}} = $id; $drvPathToId{$x->{drvPath}} = $id;
} }
# Create AggregateMembers mappings. # Create AggregateConstituents mappings.
foreach my $job (@{$jobs->{job}}) { foreach my $job (@{$jobs->{job}}) {
next unless $job->{members}; next unless $job->{constituents};
my $id = $drvPathToId{$job->{drvPath}} or die; my $id = $drvPathToId{$job->{drvPath}} or die;
foreach my $drvPath (split / /, $job->{members}) { foreach my $drvPath (split / /, $job->{constituents}) {
my $member = $drvPathToId{$drvPath}; my $constituent = $drvPathToId{$drvPath};
if (defined $member) { if (defined $constituent) {
$db->resultset('AggregateMembers')->update_or_create({aggregate => $id, member => $member}); $db->resultset('AggregateConstituents')->update_or_create({aggregate => $id, constituent => $constituent});
} else { } else {
warn "aggregate job $job->{jobName} has a member $drvPath that doesn't correspond to a Hydra build\n"; warn "aggregate job $job->{jobName} has a constituent $drvPath that doesn't correspond to a Hydra build\n";
} }
} }
} }

View file

@ -514,10 +514,10 @@ create table NewsItems (
); );
create table AggregateMembers ( create table AggregateConstituents (
aggregate integer not null references Builds(id) on delete cascade, aggregate integer not null references Builds(id) on delete cascade,
member integer not null references Builds(id) on delete cascade, constituent integer not null references Builds(id) on delete cascade,
primary key (aggregate, member) primary key (aggregate, constituent)
); );

View file

@ -1,5 +1,5 @@
create table AggregateMembers ( create table AggregateConstituents (
aggregate integer not null references Builds(id) on delete cascade, aggregate integer not null references Builds(id) on delete cascade,
member integer not null references Builds(id) on delete cascade, constituent integer not null references Builds(id) on delete cascade,
primary key (aggregate, member) primary key (aggregate, constituent)
); );