-
Notifications
You must be signed in to change notification settings - Fork 9
Update to purge functionality (D832) #607
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: dev
Are you sure you want to change the base?
Changes from 11 commits
d1f760a
f1b1484
b30c5c9
5b00901
dda4ebe
5af7b04
bbdfb77
5d01b6e
ddc5f47
155f431
54d7856
1782604
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 |
|---|---|---|
|
|
@@ -66,13 +66,18 @@ after set_value => sub { | |
| if (@values == 1 && @old == 1) | ||
| { | ||
| my $old_value = $self->schema->resultset('Fileval')->find($old[0]); # Only do one fetch here | ||
| my $old_content = $old_value->content; | ||
| my $old_name = $old_value->name; | ||
| if(my $fl = $self->schema->resultset('Fileval')->search({ | ||
| id => $values[0], | ||
| name => $old_name | ||
| })->next) { | ||
| $changed = 0 if $fl && $fl->content eq $old_content; | ||
| # Fix - if the data is originally purged, then the fileval record will have been deleted, so we need to account for that | ||
|
droberts-ctrlo marked this conversation as resolved.
|
||
| my $old_content = $old_value ? $old_value->content : undef; | ||
| my $old_name = $old_value ? $old_value->name : undef; | ||
| if (defined $old_content && defined $old_name) { | ||
| if(my $fl = $self->schema->resultset('Fileval')->search({ | ||
|
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. Just for continuity of formatting across the file, would it be worth adding a space after the |
||
| id => $values[0], | ||
| name => $old_name | ||
| })->next) { | ||
| $changed = 0 if $fl && $fl->content eq $old_content; | ||
| } | ||
| } else { | ||
| $changed = 1; | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -167,20 +172,6 @@ sub _build_files | |
| return \@return; | ||
| } | ||
|
|
||
| sub _files_rs | ||
| { my $self = shift; | ||
| [$self->schema->resultset('File')->search({ | ||
| record_id => $self->record_id, | ||
| layout_id => $self->column->id, | ||
| })->all]; | ||
| } | ||
|
|
||
| sub is_purged { | ||
| my $self = shift; | ||
| my @files = @{$self->_files_rs}; | ||
| return grep { $_->is_purged } @files; | ||
| } | ||
|
|
||
| sub _ids_to_files | ||
| { my ($self, @ids) = @_; | ||
| map { | ||
|
|
@@ -280,7 +271,7 @@ around 'clone' => sub { | |
| sub for_table | ||
| { my $self = shift; | ||
| my $return = $self->for_table_template; | ||
| $return->{values} = $self->files; | ||
| $return->{values} = $self->is_purged ? ["[purged]"] : $self->files; | ||
|
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. Does Datum::File inherit the |
||
| $return; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,14 +3,18 @@ package GADS::Role::Purgable; | |
| use strict; | ||
| use warnings; | ||
|
|
||
| use Log::Report; | ||
|
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. Is |
||
|
|
||
| use MooX::Types::MooseLike::Base qw(ArrayRef); | ||
|
|
||
| use Moo::Role; | ||
|
|
||
| has value_fields => ( | ||
| is => 'lazy', | ||
| isa => ArrayRef, | ||
| builder => sub { ['value']; } | ||
| builder => sub { | ||
| ['value']; | ||
| } | ||
| ); | ||
|
|
||
| sub is_purged { | ||
|
|
||
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.
Do we want to this be in DEBUG?