Я использовал функцию сортировки
sub sort_users {
my $self = shift;
return $self->search(undef, { order_by => [{ -desc => 'data_begin' },
{ -asc => 'username' }]});
}
для фильтрации пользователей по дате начала, и в случае равенства для сортировки по имени пользователя, база данных выглядит следующим образом:
user1 2019-09-26 00:00:00
user2 2019-09-26 00:00:00
user3 2019-09-26 00:00:00
user4 2019-09-26 00:00:00
после сортировки иногда пользователи отображаются в следующем режиме
user2, user3, user1, user4
в другое время
user1, user2, user3, user4.
РЕДАКТИРОВАТЬ
Я побежалс DBIC_TRACE = 1
и я получил:
SELECT COUNT( * ) FROM user_access_rights me WHERE ( ( access_rights_id = ? AND date_end >= ? ) ): 'level1', '2019-10-28 07:43:30+0000'
SELECT access_rights_recipient.username, access_rights_recipient.last_login, me.access_rights_id FROM user_access_rights me JOIN users access_rights_recipient ON access_rights_recipient.username = me.username WHERE ( ( access_rights_id = ? AND date_end >= ? ) ) ORDER BY date_begin DESC, username ASC LIMIT ?: 'level1', '2019-10-28 07:43:30+0000', '2'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level1', '2019-10-28T07:43:29', '2019-10-29T07:43:29', 'user1'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level1', '2019-10-28T07:43:29', '2019-10-29T07:43:29', 'user2'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level1', '2019-10-28T07:43:29', '2019-10-29T07:43:29', 'user3'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level1', '2019-10-28T07:43:29', '2019-10-29T07:43:29', 'user4'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level1', '2019-10-28T07:43:30', '2019-10-29T07:43:30', 'user5'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level2', '2019-10-28T07:43:30', '2019-10-29T07:43:30', 'user6'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level2', '2019-10-28T07:43:30', '2019-10-29T07:43:30', 'user7'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level2', '2019-10-28T07:43:30', '2019-10-29T07:43:30', 'user8'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level2', '2019-10-28T07:43:30', '2019-10-29T07:43:30', 'user9'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level2', '2019-10-28T07:43:30', '2019-10-29T07:43:30', 'user10'
INSERT INTO user_access_rights ( access_rights_id, date_begin, date_end, username) VALUES ( ?, ?, ?, ? ) RETURNING id: 'level2', '2019-10-28T07:43:30', '2019-10-29T07:43:30', 'user11'
Требует отображения user1 и user2, вместо этого отображаются user5 и user1