mirror of
https://github.com/gamaio/lobli.git
synced 2025-08-13 18:28:47 +00:00
Change click tracking to sorted set.
Using a sorted set makes it easier to sort from highest to lowest on the stats page. Minor change how tracking is done on the index and link checking has been updated.
This commit is contained in:
@@ -45,20 +45,23 @@
|
||||
|
||||
require('Include/PHP/db.php');
|
||||
|
||||
$stats = $redis->keys("tracking:clicks:*");
|
||||
rsort($stats);
|
||||
$stats = $redis->zRangeByScore("tracking:clicks", "-inf", "+inf");
|
||||
$stats = array_reverse($stats);
|
||||
$stats = array_slice($stats, 0, 5, true);
|
||||
|
||||
foreach($stats as $stat){ // There should only be 5, but the page doesn't limit how many
|
||||
$id = explode(":", $stat);
|
||||
$id = $id[2]; // Grab just the short link ID
|
||||
foreach($stats as $id){ // There should only be 5, but the page doesn't limit how many
|
||||
$trTtl = $redis->ttl("links:$id");
|
||||
if($trTtl == -2){ // The link has been deleted, no need to track it anymore
|
||||
$redis->zRem("tracking:clicks", $id;
|
||||
continue;
|
||||
}
|
||||
|
||||
$linkData = $redis->lRange("links:$id", 0, -1);
|
||||
|
||||
$link = $linkData[0];
|
||||
$title = $linkData[1];
|
||||
$date = $linkData[2];
|
||||
$trackClicks = $redis->get("tracking:clicks:$id");
|
||||
$trackClicks = $redis->zScore("tracking:clicks", $id);
|
||||
|
||||
echo "
|
||||
<tr class=\"success\">
|
||||
|
Reference in New Issue
Block a user