summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2017-02-20 18:11:25 +0100
committerYorhel <git@yorhel.nl>2017-02-20 18:11:25 +0100
commit96f3499884e5290a33b263cca81feac16e3df524 (patch)
tree634d4db432eb92a2d09905c14622bc044d13d35a /lib
parente2408d8312fecac6ee05b488ec0d478fd7a5f619 (diff)
APIDump: Add votes2.gz with dates, update sizes in d14
Diffstat (limited to 'lib')
-rw-r--r--lib/Multi/APIDump.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Multi/APIDump.pm b/lib/Multi/APIDump.pm
index d3454e72..2ba44156 100644
--- a/lib/Multi/APIDump.pm
+++ b/lib/Multi/APIDump.pm
@@ -79,7 +79,7 @@ sub writejson {
sub votes_gen {
pg_cmd q{
- SELECT vv.vid||' '||vv.uid||' '||vv.vote as l
+ SELECT vv.vid||' '||vv.uid||' '||vv.vote as l, to_char(vv.date, 'YYYY-MM-DD') as d
FROM votes vv
JOIN users u ON u.id = vv.uid
JOIN vn v ON v.id = vv.vid
@@ -91,12 +91,20 @@ sub votes_gen {
return if pg_expect $res, 1;
my $ws = AE::time;
+ # legacy votes v1 file, without date
my $file = "$VNDB::ROOT/www/api/votes.gz";
open my $f, '>:gzip:utf8', "$file~" or die "Writing $file: $!";
printf $f "%s\n", $res->value($_,0) for (0 .. $res->rows-1);
close $f;
rename "$file~", $file or die "Renaming $file: $!";
+ # v2 file with date
+ $file = "$VNDB::ROOT/www/api/votes2.gz";
+ open $f, '>:gzip:utf8', "$file~" or die "Writing $file: $!";
+ printf $f "%s %s\n", $res->value($_,0), $res->value($_,1) for (0 .. $res->rows-1);
+ close $f;
+ rename "$file~", $file or die "Renaming $file: $!";
+
my $wt = AE::time-$ws;
AE::log info => sprintf 'Wrote %s in %.2fs query + %.2fs write, size: %.1fkB, items: %d.',
$file, $time, $wt, (-s $file)/1024, scalar $res->rows;