blib/lib/Mojolicious/Plugin/Fondation/User/Schema/ResultSet/User.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 38 CC 1 SCAR 6.9
CC
1
Cov
0%
active
2.0
created_today
2.0
search_by_login
2.0
CRAP 2.0
1 package Mojolicious::Plugin::Fondation::User::Schema::ResultSet::User;
2 # ABSTRACT: DBIx::Class ResultSet class for users table
3 $Mojolicious::Plugin::Fondation::User::Schema::ResultSet::User::VERSION = '0.04';
4 use base 'DBIx::Class::ResultSet';
5  
6 use strict;
7 use warnings;
8 use DateTime;
9  
10 # Example of useful method: active users (if you add an 'active' field)
11 sub active {
12 shift->search({ active => 1 });
13 }
14  
15 # Example: users created today
16 sub created_today {
17 my $self = shift;
18 my $today = DateTime->today->strftime('%Y-%m-%d');
19 return $self->search({
20 created_at => { '>=' => $today, '<' => DateTime->today->add( days => 1 )->strftime('%Y-%m-%d') },
21 });
22 }
23  
24 # Example: search by email or username (case insensitive)
25 sub search_by_login {
26 my ($self, $login) = @_;
27 return $self->search([
28 { username => { -like => "%$login%" } },
29 { email => { -like => "%$login%" } },
30 ]);
31 }
32  
33 # Example: latest registered user (sorted by created_at DESC)
34 sub latest {
35 shift->search(undef, { order_by => { -desc => 'created_at' }, rows => 10 });
36 }
37  
38 1;
39  
40 __END__