From 7791d0236a9bcd85ea3542360b0c68a8492a909e Mon Sep 17 00:00:00 2001
From: Yorhel <git@yorhel.nl>
Date: Sat, 14 Nov 2009 19:04:44 +0100
Subject: SQL: Allow NULL for vn.c_popularity

Sorting from least to most popular VN make sense now, you won't have to
wade through those entries without any vote at all.
---
 util/dump.sql | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'util/dump.sql')

diff --git a/util/dump.sql b/util/dump.sql
index 43562da3..a5451395 100644
--- a/util/dump.sql
+++ b/util/dump.sql
@@ -291,7 +291,7 @@ CREATE TABLE vn (
   c_released integer NOT NULL DEFAULT 0,
   c_languages varchar(32) NOT NULL DEFAULT '',
   c_platforms varchar(32) NOT NULL DEFAULT '',
-  c_popularity real NOT NULL DEFAULT 0,
+  c_popularity real,
   c_rating real,
   c_votecount integer NOT NULL DEFAULT 0
 );
@@ -485,7 +485,7 @@ BEGIN
     GROUP BY v.vid, v.uid;
   CREATE OR REPLACE TEMP VIEW tmp_pop2 (vid, win) AS
     SELECT vid, sum(rank) FROM tmp_pop1 GROUP BY vid;
-  UPDATE vn SET c_popularity = COALESCE((SELECT win/(SELECT MAX(win) FROM tmp_pop2) FROM tmp_pop2 WHERE vid = id), 0);
+  UPDATE vn SET c_popularity = (SELECT win/(SELECT MAX(win) FROM tmp_pop2) FROM tmp_pop2 WHERE vid = id);
   RETURN;
 END;
 $$ LANGUAGE plpgsql;
-- 
cgit v1.2.3

