diff options
author | Yorhel <git@yorhel.nl> | 2020-04-24 16:00:28 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-04-24 16:00:34 +0200 |
commit | 493866f8114dc785433e401b4e3203516be9f71b (patch) | |
tree | e71aad73b32e0fa909d0866cdf374c574b19cb11 /lib/VNDB/DB | |
parent | 935d17e532e8d382e4db22f197a5f53a4cc94f98 (diff) |
v2rw/VN::Page: Remove old and unused code
There's a lot of unused code in VNDB::DB::{VN,Release} still, but I'll
not fiddle with that for now.
Diffstat (limited to 'lib/VNDB/DB')
-rw-r--r-- | lib/VNDB/DB/ULists.pm | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm deleted file mode 100644 index 4c1d10ae..00000000 --- a/lib/VNDB/DB/ULists.pm +++ /dev/null @@ -1,77 +0,0 @@ - -package VNDB::DB::ULists; - -use strict; -use warnings; -use Exporter 'import'; - - -our @EXPORT = qw| - dbRListGet dbRListAdd dbRListDel - dbVoteStats -|; - - -# Options: uid rid -sub dbRListGet { - my($self, %o) = @_; - - my %where = ( - 'uid = ?' => $o{uid}, - $o{rid} ? ('rid IN(!l)' => [ ref $o{rid} ? $o{rid} : [$o{rid}] ]) : (), - ); - - return $self->dbAll(q| - SELECT uid, rid, status - FROM rlists - !W|, - \%where - ); -} - - -# Arguments: uid rid status -# rid can be an arrayref only when the rows are already present, in which case an update is done -sub dbRListAdd { - my($self, $uid, $rid, $stat) = @_; - $self->dbExec( - 'UPDATE rlists SET status = ? WHERE uid = ? AND rid IN(!l)', - $stat, $uid, ref($rid) ? $rid : [ $rid ] - ) - || - $self->dbExec( - 'INSERT INTO rlists (uid, rid, status) VALUES(?, ?, ?)', - $uid, $rid, $stat - ); -} - - -# Arguments: uid, rid -sub dbRListDel { - my($self, $uid, $rid) = @_; - $self->dbExec( - 'DELETE FROM rlists WHERE uid = ? AND rid IN(!l)', - $uid, ref($rid) ? $rid : [ $rid ] - ); -} - - -# Arguments: 'vid', id -# Returns an arrayref with 10 elements containing the [ count(vote), sum(vote) ] -# for votes in the range of ($index+0.5) .. ($index+1.4) -sub dbVoteStats { - my($self, $col, $id, $ign) = @_; - my $r = [ map [0,0], 0..9 ]; - $r->[$_->{idx}] = [ $_->{votes}, $_->{total} ] for (@{$self->dbAll(q| - SELECT (vote::numeric/10)::int-1 AS idx, COUNT(vote) as votes, SUM(vote) AS total - FROM ulist_vns uv - WHERE uv.vote IS NOT NULL AND NOT EXISTS(SELECT 1 FROM users u WHERE u.id = uv.uid AND u.ign_votes) - AND uv.vid = ? - GROUP BY (vote::numeric/10)::int|, - $id - )}); - return $r; -} - -1; - |