1.16KiB; Perl | 2018-01-25 22:24:04+01 | Statements 23 | SLOC 27
1
package Ged2site::Display::todo;
2
3
use warnings;
4
use strict;
5
6
# Display the todo page
7
8
use Ged2site::Display;
9
10
our @ISA = ('Ged2site::Display');
11
12
sub html {
13
	my $self = shift;
14
	my %args = (ref($_[0]) eq 'HASH') ? %{$_[0]} : @_;
15
16
	my $todohash;	# hash of person's name to array of todos for that person, each todo is a hash of the todo's details
17
18
	my $todo = $args{'todo'};	# Handle into the database
19
	my $people = $args{'people'};
20
21
	# TODO: handle situation where look up fails
22
23
	# Create a list of entries in the TODO table, sorted by title
24
	my @todos = sort { $a->{'title'} cmp $b->{'title'} } $todo->selectall_hash();
25
26
	# Now create a list of hashes, each list is a list of entries in the todo table with the same summary field, the earlier
27
	# sort ensures that the list will be sorted by title
28
	foreach my $t(@todos) {
29
		# Ensure only list a person once per summary
30 1
		push(@{$todohash->{$t->{'summary'}}}, $t) if(!grep { $_->{'title'} eq $t->{'title'} } @{$todohash->{$t->{'summary'}}});
BuiltinFunctions::ProhibitBooleanGrep "grep" used in boolean context (kritika/PerlCritic) Filter like this
31
	}
32
33
	# use Data::Dumper;
34
	# print Data::Dumper->new([$todohash])->Dump();
35
	# return $self->SUPER::html();
36
37
	return $self->SUPER::html({ todos => $todohash, updated => $todo->updated() });
38
}
39
40
1;