line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::Schema::Result::PageVersion; |
2
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
36970
|
use strict; |
|
40
|
|
|
|
|
101
|
|
|
40
|
|
|
|
|
1074
|
|
4
|
40
|
|
|
40
|
|
207
|
use warnings; |
|
40
|
|
|
|
|
97
|
|
|
40
|
|
|
|
|
1102
|
|
5
|
|
|
|
|
|
|
|
6
|
40
|
|
|
40
|
|
199
|
use parent qw/MojoMojo::Schema::Base::Result/; |
|
40
|
|
|
|
|
88
|
|
|
40
|
|
|
|
|
235
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
MojoMojo::Schema::Result::PageVersion - Versioned page metadata |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This table implements versioning of page metadata (not content, see |
15
|
|
|
|
|
|
|
L<MojoMojo::Schema::Result::Content> for that). It has a composite |
16
|
|
|
|
|
|
|
primary key C<(page, version)>. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
When renaming a page, a new version is created in this table, with |
19
|
|
|
|
|
|
|
C<version> set to 1 + the maximum version for that C<page>. The |
20
|
|
|
|
|
|
|
C<status> of the new C<page_version> is set to "released", its |
21
|
|
|
|
|
|
|
C<release_date> is set to C<< DateTime->now >>, while the old |
22
|
|
|
|
|
|
|
C<page_version>'s status is set to 'removed' and its C<remove_date> |
23
|
|
|
|
|
|
|
is set to C<< DateTime->now >>. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 TODO |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=over 4 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item * document the relationships |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item * in order to support proper rollback, meaning creating a new |
32
|
|
|
|
|
|
|
version for the rollback operation itself, a C<content_version> |
33
|
|
|
|
|
|
|
field needs to be added. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item * C<created> is apparently unused: set to 0 for pages populated when |
36
|
|
|
|
|
|
|
creating the database, and NULL for all normal pages. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=back |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__PACKAGE__->load_components( "Core" ); |
43
|
|
|
|
|
|
|
__PACKAGE__->table("page_version"); |
44
|
|
|
|
|
|
|
__PACKAGE__->add_columns( |
45
|
|
|
|
|
|
|
"page", { data_type => "INTEGER", is_nullable => 0, size => undef }, |
46
|
|
|
|
|
|
|
"version", { data_type => "INTEGER", is_nullable => 0, size => undef }, |
47
|
|
|
|
|
|
|
"parent", { data_type => "INTEGER", is_nullable => 1, size => undef }, |
48
|
|
|
|
|
|
|
"parent_version", { data_type => "INTEGER", is_nullable => 1, size => undef }, |
49
|
|
|
|
|
|
|
"name", { data_type => "VARCHAR", is_nullable => 0, size => 200 }, |
50
|
|
|
|
|
|
|
"name_orig", { data_type => "VARCHAR", is_nullable => 0, size => 200 }, |
51
|
|
|
|
|
|
|
"depth", { data_type => "INTEGER", is_nullable => 0, size => undef }, |
52
|
|
|
|
|
|
|
"creator", { data_type => "INTEGER", is_nullable => 0, size => undef }, |
53
|
|
|
|
|
|
|
"created", { data_type => "VARCHAR", is_nullable => 1, size => 100 }, |
54
|
|
|
|
|
|
|
"status", { data_type => "VARCHAR", is_nullable => 0, size => 20 }, |
55
|
|
|
|
|
|
|
"release_date", { data_type => "VARCHAR", is_nullable => 0, size => 100 }, |
56
|
|
|
|
|
|
|
"remove_date", { data_type => "VARCHAR", is_nullable => 1, size => 100 }, |
57
|
|
|
|
|
|
|
"comments", { data_type => "TEXT", is_nullable => 1, size => 4000 }, |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# FIXME: in a wiki in which I had never rolled back a page (that is, never made a second |
60
|
|
|
|
|
|
|
# revision current, I see in the page_version table that some pages have |
61
|
|
|
|
|
|
|
# content_version_first and content_version_last (1, 1) and others (NULL, NULL). --dandv |
62
|
|
|
|
|
|
|
"content_version_first", { data_type => "INTEGER", is_nullable => 1, size => undef }, |
63
|
|
|
|
|
|
|
"content_version_last", { data_type => "INTEGER", is_nullable => 1, size => undef }, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
__PACKAGE__->set_primary_key( "page", "version" ); |
66
|
|
|
|
|
|
|
__PACKAGE__->has_many( |
67
|
|
|
|
|
|
|
pages => "MojoMojo::Schema::Result::Page", |
68
|
|
|
|
|
|
|
{ |
69
|
|
|
|
|
|
|
"foreign.id" => "self.page", |
70
|
|
|
|
|
|
|
"foreign.version" => "self.version" |
71
|
|
|
|
|
|
|
}, |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
__PACKAGE__->belongs_to( "creator", "MojoMojo::Schema::Result::Person", { id => "creator" } ); |
74
|
|
|
|
|
|
|
__PACKAGE__->belongs_to( "page", "MojoMojo::Schema::Result::Page", { id => "page" }, ); |
75
|
|
|
|
|
|
|
__PACKAGE__->belongs_to( |
76
|
|
|
|
|
|
|
content => "MojoMojo::Schema::Result::Content", |
77
|
|
|
|
|
|
|
{ |
78
|
|
|
|
|
|
|
page => "page", |
79
|
|
|
|
|
|
|
version => "content_version_first" |
80
|
|
|
|
|
|
|
}, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
__PACKAGE__->belongs_to( |
83
|
|
|
|
|
|
|
content => "MojoMojo::Schema::Result::Content", |
84
|
|
|
|
|
|
|
{ |
85
|
|
|
|
|
|
|
page => "page", |
86
|
|
|
|
|
|
|
version => "content_version_last" |
87
|
|
|
|
|
|
|
}, |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
__PACKAGE__->belongs_to( |
90
|
|
|
|
|
|
|
page_version => "MojoMojo::Schema::Result::PageVersion", |
91
|
|
|
|
|
|
|
{ |
92
|
|
|
|
|
|
|
page => "parent", |
93
|
|
|
|
|
|
|
version => "parent_version" |
94
|
|
|
|
|
|
|
}, |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
__PACKAGE__->has_many( |
97
|
|
|
|
|
|
|
"page_versions", |
98
|
|
|
|
|
|
|
"MojoMojo::Schema::Result::PageVersion", |
99
|
|
|
|
|
|
|
{ |
100
|
|
|
|
|
|
|
"foreign.parent" => "self.page", |
101
|
|
|
|
|
|
|
"foreign.parent_version" => "self.version", |
102
|
|
|
|
|
|
|
}, |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 METHODS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 latest_version |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Return the L<PageVersion|MojoMojo::Schema::Result::PageVersion> object |
112
|
|
|
|
|
|
|
having the latest version of this page. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub latest_version { |
117
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
118
|
0
|
|
|
|
|
|
my $latest = $self->result_source->resultset->search( |
119
|
|
|
|
|
|
|
{ |
120
|
|
|
|
|
|
|
page => $self->page->id |
121
|
|
|
|
|
|
|
}, |
122
|
|
|
|
|
|
|
{ |
123
|
|
|
|
|
|
|
order_by => 'version DESC', |
124
|
|
|
|
|
|
|
rows => 1 |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
)->single; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return $latest; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 AUTHOR |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Marcus Ramberg <mramberg@cpan.org> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 LICENSE |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify |
138
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |