]>
Commit | Line | Data |
---|---|---|
1 | use utf8; | |
2 | package Gruntmaster::Data::Result::ContestStatus; | |
3 | ||
4 | # Created by DBIx::Class::Schema::Loader | |
5 | # DO NOT MODIFY THE FIRST PART OF THIS FILE | |
6 | ||
7 | =head1 NAME | |
8 | ||
9 | Gruntmaster::Data::Result::ContestStatus - List of (contest, user, result) | |
10 | ||
11 | =cut | |
12 | ||
13 | use strict; | |
14 | use warnings; | |
15 | ||
16 | use base 'DBIx::Class::Core'; | |
17 | ||
18 | =head1 TABLE: C<contest_status> | |
19 | ||
20 | =cut | |
21 | ||
22 | __PACKAGE__->table("contest_status"); | |
23 | ||
24 | =head1 ACCESSORS | |
25 | ||
26 | =head2 contest | |
27 | ||
28 | data_type: 'text' | |
29 | is_foreign_key: 1 | |
30 | is_nullable: 0 | |
31 | ||
32 | =head2 owner | |
33 | ||
34 | data_type: 'text' | |
35 | is_foreign_key: 1 | |
36 | is_nullable: 0 | |
37 | ||
38 | =head2 score | |
39 | ||
40 | data_type: 'integer' | |
41 | is_nullable: 0 | |
42 | ||
43 | =head2 rank | |
44 | ||
45 | data_type: 'integer' | |
46 | is_nullable: 0 | |
47 | ||
48 | =cut | |
49 | ||
50 | __PACKAGE__->add_columns( | |
51 | "contest", | |
52 | { data_type => "text", is_foreign_key => 1, is_nullable => 0 }, | |
53 | "owner", | |
54 | { data_type => "text", is_foreign_key => 1, is_nullable => 0 }, | |
55 | "score", | |
56 | { data_type => "integer", is_nullable => 0 }, | |
57 | "rank", | |
58 | { data_type => "integer", is_nullable => 0 }, | |
59 | ); | |
60 | ||
61 | =head1 PRIMARY KEY | |
62 | ||
63 | =over 4 | |
64 | ||
65 | =item * L</owner> | |
66 | ||
67 | =item * L</contest> | |
68 | ||
69 | =back | |
70 | ||
71 | =cut | |
72 | ||
73 | __PACKAGE__->set_primary_key("owner", "contest"); | |
74 | ||
75 | =head1 RELATIONS | |
76 | ||
77 | =head2 contest | |
78 | ||
79 | Type: belongs_to | |
80 | ||
81 | Related object: L<Gruntmaster::Data::Result::Contest> | |
82 | ||
83 | =cut | |
84 | ||
85 | __PACKAGE__->belongs_to( | |
86 | "contest", | |
87 | "Gruntmaster::Data::Result::Contest", | |
88 | { id => "contest" }, | |
89 | { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, | |
90 | ); | |
91 | ||
92 | =head2 owner | |
93 | ||
94 | Type: belongs_to | |
95 | ||
96 | Related object: L<Gruntmaster::Data::Result::User> | |
97 | ||
98 | =cut | |
99 | ||
100 | __PACKAGE__->belongs_to( | |
101 | "owner", | |
102 | "Gruntmaster::Data::Result::User", | |
103 | { id => "owner" }, | |
104 | { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, | |
105 | ); | |
106 | ||
107 | ||
108 | # Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-19 16:44:22 | |
109 | # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IkY4FNON0SrxrP8oNOXoHg | |
110 | ||
111 | use Class::Method::Modifiers qw/after/; | |
112 | ||
113 | sub rawowner { shift->get_column('owner') } | |
114 | ||
115 | after qw/insert update delete/ => sub { | |
116 | my ($self) = @_; | |
117 | Gruntmaster::Data::purge '/us/'; | |
118 | Gruntmaster::Data::purge '/us/' . $self->rawowner; | |
119 | }; | |
120 | ||
121 | 1; |