Skip to content

Commit 13381ab

Browse files
Update Lists.php
1 parent 4e1b746 commit 13381ab

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/Traits/Lists.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@
66

77
trait Lists
88
{
9+
/**
10+
* Fetch all time trending subjects Ids.
11+
*
12+
* @param int $limit
13+
* @param array $constraints optional. filter models by attributes (where=[...])
14+
* @return array
15+
*/
16+
public function topIds($limit = 5, $orderByAsc = false, $constraints = [])
17+
{
18+
if(is_array($orderByAsc)) {
19+
$constraints = $orderByAsc;
20+
$orderByAsc = false;
21+
}
22+
23+
$cacheKey = $this->keys->cache($limit, $orderByAsc, $constraints);
24+
25+
$cachedList = $this->cachedList($limit, $cacheKey);
26+
return $this->getVisitsIds($limit, $this->keys->visits, $orderByAsc);
27+
}
28+
929
/**
1030
* Fetch all time trending subjects.
1131
*
@@ -71,6 +91,19 @@ protected function getSortedList($name, $limit, $orderByAsc = false, $withValues
7191
return $this->connection->valueList($this->keys->visits . "_{$name}:{$this->keys->id}", $limit, $orderByAsc, $withValues);
7292
}
7393

94+
95+
/**
96+
* Fetch lowest subjects Ids.
97+
*
98+
* @param int $limit
99+
* @param array $constraints optional
100+
* @return array
101+
*/
102+
public function lowIds($limit = 5, $constraints = [])
103+
{
104+
return $this->topIds($limit, true, $constraints);
105+
}
106+
74107
/**
75108
* Fetch lowest subjects.
76109
*

0 commit comments

Comments
 (0)