Removed execution flag from non-exe files
[Fumo.git] / lib / Fumo / Schema / File.pm
blob472fc910438b471bd07135ac36a667e1138e7a64
1 package Fumo::Schema::File;
3 use strict;
4 use warnings;
6 use base 'DBIx::Class';
8 __PACKAGE__->load_components("Core");
9 __PACKAGE__->table("file");
10 __PACKAGE__->add_columns(
11 "name",
12 { data_type => "VARCHAR", default_value => "", is_nullable => 0, size => 128 },
13 "project",
14 { data_type => "VARCHAR", default_value => "", is_nullable => 0, size => 128 },
15 "branch",
16 { data_type => "VARCHAR", default_value => "", is_nullable => 0, size => 128 },
17 "revision",
18 { data_type => "VARCHAR", default_value => "", is_nullable => 0, size => 128 },
19 "test_count",
20 { data_type => "INT", default_value => "", is_nullable => 0, size => 11 },
21 "created",
22 { data_type => "DATETIME", default_value => "", is_nullable => 0, size => 19 },
23 "pass_rate",
24 { data_type => "FLOAT", default_value => 0, is_nullable => 0, size => 32 },
26 __PACKAGE__->set_primary_key("name", "project", "branch", "revision");
27 __PACKAGE__->belongs_to("branch", "Fumo::Schema::Branch", { name => "branch" });
28 __PACKAGE__->belongs_to("project", "Fumo::Schema::Project", { name => "project" });
29 __PACKAGE__->belongs_to("revision", "Fumo::Schema::Revision", { name => "revision" });
30 __PACKAGE__->has_many(
31 "tests",
32 "Fumo::Schema::Test",
33 { "foreign.file" => "self.name" },
37 # Created by DBIx::Class::Schema::Loader v0.04001 @ 2007-07-20 22:25:16
38 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:47+jRPE2lQskHivy9bN5hw
40 use DateTime;
42 sub insert {
43 my $self = shift;
45 $self->created(DateTime->now);
47 return $self->next::method(@_);
50 sub pass_rates {
51 my ($self, $project, $branch, $revision) = @_;
53 $self->search_related('tests',
54 { directive => undef },
56 select => [ 'status', { count => 'status' } ],
57 as => [ 'status', 'status_count' ],
58 group_by => 'status'
63 sub tests_by_status {
64 my ($self, $status, $project, $branch, $revision) = @_;
66 # only allow the valid test types through
67 my $search = {
68 project => $project,
69 branch => $branch,
70 revision => $revision
73 if ($status) {
74 $search->{status} = $status;
75 $search->{directive} = undef;
78 return $self->search_related('tests', $search, {
79 order_by => 'number'
80 });