[art-web] Use weighted popularity for sorting
- From: Thomas Wood <thos src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [art-web] Use weighted popularity for sorting
- Date: Wed, 30 Dec 2009 20:45:24 +0000 (UTC)
commit 4875b2ebf86d67e0e57a05da459564299fe91850
Author: Thomas Wood <thos gnome org>
Date: Wed Dec 30 20:45:18 2009 +0000
Use weighted popularity for sorting
Calculate weighted popularity by normalising the download count against the
number of days an item has been available.
controllers/backgrounds.php | 2 +-
controllers/themes.php | 2 +-
models/backgrounds.php | 7 ++++++-
models/themes.php | 5 ++++-
4 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/controllers/backgrounds.php b/controllers/backgrounds.php
index a56d2f9..8bc472c 100644
--- a/controllers/backgrounds.php
+++ b/controllers/backgrounds.php
@@ -72,7 +72,7 @@ if ($sort)
else if ($sort == 'name')
$sortby = 'background.name';
else if ($sort == 'popularity')
- $sortby = 'background.download_count DESC';
+ $sortby = 'popularity DESC';
else
$sortby = 'name';
}
diff --git a/controllers/themes.php b/controllers/themes.php
index f25e340..b45f2bd 100644
--- a/controllers/themes.php
+++ b/controllers/themes.php
@@ -66,7 +66,7 @@ if ($sort)
else if ($sort == 'name')
$sortby = 'name';
else if ($sort == 'popularity')
- $sortby = 'download_count DESC';
+ $sortby = 'popularity DESC';
else
$sortby = 'name';
}
diff --git a/models/backgrounds.php b/models/backgrounds.php
index 07afb19..b1f961f 100644
--- a/models/backgrounds.php
+++ b/models/backgrounds.php
@@ -32,7 +32,12 @@ class BackgroundsModel extends ArtModel
AND background.backgroundID > 1000
ORDER BY %s LIMIT %s,%s";
- var $get_filtered_items_sql = "SELECT * FROM background
+ var $get_filtered_items_sql =
+ "SELECT
+ *,
+ (download_count / (UNIX_TIMESTAMP() - download_start_timestamp))
+ AS popularity
+ FROM background
INNER JOIN user ON background.userID = user.userID
RIGHT JOIN background_resolution
ON background_resolution.backgroundID = background.backgroundID
diff --git a/models/themes.php b/models/themes.php
index 14db590..ef405bf 100644
--- a/models/themes.php
+++ b/models/themes.php
@@ -26,7 +26,10 @@ class ThemesModel extends ArtModel
AND theme.userID = user.userID
AND theme.themeID = %s";
- var $get_items_sql = "SELECT * FROM theme,user
+ var $get_items_sql = "SELECT *,
+ (download_count / (UNIX_TIMESTAMP() - download_start_timestamp))
+ AS popularity
+ FROM theme,user
WHERE status='active' AND category = '%s'
AND theme.userID = user.userID
AND theme.themeID > 1000
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]