summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/Affiliates.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2011-05-03 10:14:37 +0200
committerYorhel <git@yorhel.nl>2011-05-03 10:14:37 +0200
commit8da57d32fae2989438c8b509821c339464d26c82 (patch)
treef5f2e136d37e38e2f6ac1df65ca1382dfc9aa37c /lib/VNDB/DB/Affiliates.pm
parent50a94610a570c16f1e4c9ffcadc60739d4a30b82 (diff)
affiliates: Expose some columns and allow price without lastfetch
This allows the price info to be manually set without worrying about the lastfetch. Would be useful with MangaGamer.
Diffstat (limited to 'lib/VNDB/DB/Affiliates.pm')
-rw-r--r--lib/VNDB/DB/Affiliates.pm12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/VNDB/DB/Affiliates.pm b/lib/VNDB/DB/Affiliates.pm
index 51320b47..51f8c2dc 100644
--- a/lib/VNDB/DB/Affiliates.pm
+++ b/lib/VNDB/DB/Affiliates.pm
@@ -36,7 +36,7 @@ sub dbAffiliateGet {
return $self->dbAll(qq|
SELECT af.id, af.rid, af.hidden, af.priority, af.affiliate, af.url, af.version,
- extract('epoch' from af.lastfetch) as lastfetch, af.price$select
+ extract('epoch' from af.lastfetch) as lastfetch, af.price, af.data$select
FROM affiliate_links af
$join
!W
@@ -53,15 +53,19 @@ sub dbAffiliateDel {
sub dbAffiliateEdit {
my($self, $id, %ops) = @_;
my %set;
- exists($ops{$_}) && ($set{"$_ = ?"} = $ops{$_}) for(qw|rid priority hidden affiliate url version|);
+ exists($ops{$_}) && ($set{"$_ = ?"} = $ops{$_}) for(qw|rid priority hidden affiliate url version price data|);
+ $set{"lastfetch = TIMESTAMP WITH TIME ZONE 'epoch' + ? * INTERVAL '1 second'"} = $ops{lastfetch} || $ops{lastfetch} eq '0' ? $ops{lastfetch} : undef if exists $ops{lastfetch};
return if !keys %set;
$self->dbExec('UPDATE affiliate_links !H WHERE id = ?', \%set, $id);
}
+
sub dbAffiliateAdd {
my($self, %ops) = @_;
- $self->dbExec('INSERT INTO affiliate_links (rid, priority, hidden, affiliate, url, version) VALUES(!l)',
- [@ops{qw| rid priority hidden affiliate url version|}]);
+ $self->dbExec(q|INSERT INTO affiliate_links (rid, priority, hidden, affiliate, url, version, price, data, lastfetch)
+ VALUES(!l, TIMESTAMP WITH TIME ZONE 'epoch' + ? * INTERVAL '1 second')|,
+ [@ops{qw| rid priority hidden affiliate url version price data|}],
+ $ops{lastfetch} || $ops{lastfetch} eq '0' ? $ops{lastfetch} : undef);
}