-
Notifications
You must be signed in to change notification settings - Fork 203
Bug 1806896 - Move flag_state_activity to core as flag_activity #2657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 7 commits
4f6ee4c
69c5c5f
2179321
cc566e3
78192e7
e4f6327
4cbf179
6fadea6
0591975
9bc7c0b
ea1f4b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| # | ||
| # This Source Code Form is "Incompatible With Secondary Licenses", as | ||
| # defined by the Mozilla Public License, v. 2.0. | ||
|
|
||
| package Bugzilla::FlagActivity; | ||
|
|
||
| use 5.10.1; | ||
| use strict; | ||
| use warnings; | ||
|
|
||
| use Bugzilla::Error qw(ThrowUserError); | ||
| use Bugzilla::Util qw(trim datetime_from); | ||
| use List::MoreUtils qw(none); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by modifying line 14 to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or just use
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line modified to |
||
|
|
||
| use base qw( Bugzilla::Object ); | ||
|
|
||
| use constant DB_TABLE => 'flag_activity'; | ||
| use constant LIST_ORDER => 'id'; | ||
| use constant AUDIT_CREATES => 0; | ||
| use constant AUDIT_UPDATES => 0; | ||
| use constant AUDIT_REMOVES => 0; | ||
|
|
||
| use constant DB_COLUMNS => qw( | ||
| id | ||
| flag_when | ||
| type_id | ||
| flag_id | ||
| setter_id | ||
| requestee_id | ||
| bug_id | ||
| attachment_id | ||
| status | ||
| ); | ||
|
|
||
| sub _check_param_required { | ||
| my ($param) = @_; | ||
|
|
||
| return sub { | ||
| my ($invocant, $value) = @_; | ||
| $value = trim($value) or ThrowCodeError('param_required', {param => $param}); | ||
| return $value; | ||
| },; | ||
| } | ||
|
|
||
| sub _check_date { | ||
| my ($invocant, $date) = @_; | ||
|
|
||
| $date = trim($date); | ||
| datetime_from($date) | ||
| or ThrowUserError('illegal_date', | ||
| {date => $date, format => 'YYYY-MM-DD HH24:MI:SS'}); | ||
| return $date; | ||
| } | ||
|
|
||
| sub _check_status { | ||
| my ($self, $status) = @_; | ||
|
|
||
| if (none { $status eq $_ } qw( X + - ? )) { | ||
| ThrowUserError('flag_status_invalid', {id => $self->id, status => $status}); | ||
| } | ||
| return $status; | ||
| } | ||
|
|
||
| use constant VALIDATORS => { | ||
| flag_when => \&_check_date, | ||
| type_id => _check_param_required('type_id'), | ||
| flag_id => _check_param_required('flag_id'), | ||
| setter_id => _check_param_required('setter_id'), | ||
| bug_id => _check_param_required('bug_id'), | ||
| status => \&_check_status, | ||
| }; | ||
|
|
||
| sub flag_when { return $_[0]->{flag_when} } | ||
| sub type_id { return $_[0]->{type_id} } | ||
| sub flag_id { return $_[0]->{flag_id} } | ||
| sub setter_id { return $_[0]->{setter_id} } | ||
| sub bug_id { return $_[0]->{bug_id} } | ||
| sub requestee_id { return $_[0]->{requestee_id} } | ||
| sub attachment_id { return $_[0]->{attachment_id} } | ||
| sub status { return $_[0]->{status} } | ||
|
|
||
| sub type { | ||
| my ($self) = @_; | ||
| return $self->{type} | ||
| //= Bugzilla::FlagType->new({id => $self->type_id, cache => 1}); | ||
| } | ||
|
|
||
| sub setter { | ||
| my ($self) = @_; | ||
| return $self->{setter} | ||
| //= Bugzilla::User->new({id => $self->setter_id, cache => 1}); | ||
| } | ||
|
|
||
| sub requestee { | ||
| my ($self) = @_; | ||
| return undef unless defined $self->requestee_id; | ||
| return $self->{requestee} | ||
| //= Bugzilla::User->new({id => $self->requestee_id, cache => 1}); | ||
| } | ||
|
|
||
| sub bug { | ||
| my ($self) = @_; | ||
| return $self->{bug} //= Bugzilla::Bug->new({id => $self->bug_id, cache => 1}); | ||
| } | ||
|
|
||
| sub attachment { | ||
| my ($self) = @_; | ||
| return $self->{attachment} | ||
| //= Bugzilla::Attachment->new({id => $self->attachment_id, cache => 1}); | ||
| } | ||
|
|
||
| 1; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in "Bug 1806896 - Add status/flag_when index to flag_activity" commit