summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-11-03 11:04:22 +0100
committerYorhel <git@yorhel.nl>2010-11-03 11:06:02 +0100
commitbb3f32e88166fad0c1a5bad5762f2618eeed6437 (patch)
tree3855d9585a3b0ebd5a77d429a0d9e816c7a838a8 /lib
parent97eb068a5f6b3a6e3c10ffc4f7230bf2342b3102 (diff)
parentf72772a0e741399e2fcb3b83f54d0d8ac52b4d2c (diff)
Merge branch 'master' into beta
Conflicts: lib/VNDB/DB/VN.pm lib/VNDB/Func.pm
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/ULists.pm4
-rw-r--r--lib/VNDB/Handler/Releases.pm1
-rw-r--r--lib/VNDBUtil.pm8
3 files changed, 7 insertions, 6 deletions
diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm
index 19831593..e926bae4 100644
--- a/lib/VNDB/DB/ULists.pm
+++ b/lib/VNDB/DB/ULists.pm
@@ -47,13 +47,13 @@ sub dbVNListList {
# construct the global WHERE clause
my $where = $o{voted} != -1 ? 'vo.vote IS NOT NULL' : '';
- $where .= ($where?' OR ':'').q|v.id IN(
+ $where .= ($where?' OR ':'').q|v.id = ANY(ARRAY(
SELECT irv.vid
FROM rlists irl
JOIN releases ir ON ir.id = irl.rid
JOIN releases_vn irv ON irv.rid = ir.latest
WHERE uid = ?
- )| if $o{voted} != 1;
+ ))| if $o{voted} != 1;
$where = '('.$where.') AND LOWER(SUBSTR(vr.title, 1, 1)) = \''.$o{char}.'\'' if $o{char};
$where = '('.$where.') AND (ASCII(vr.title) < 97 OR ASCII(vr.title) > 122) AND (ASCII(vr.title) < 65 OR ASCII(vr.title) > 90)' if defined $o{char} && !$o{char};
$where = '('.$where.') AND vo.vote IS NULL' if $o{voted} == -1;
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index 55bc9778..840b29f0 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -295,6 +295,7 @@ sub edit {
sort { $a->{id} <=> $b->{id} } @{$r->{producers}}
),
);
+ gtintype($b4{gtin}) if $b4{gtin}; # normalize gtin code
$b4{vn} = join('|||', map "$_->{vid},$_->{title}", @$vn);
my $frm;
diff --git a/lib/VNDBUtil.pm b/lib/VNDBUtil.pm
index 48b5f01b..bda54383 100644
--- a/lib/VNDBUtil.pm
+++ b/lib/VNDBUtil.pm
@@ -134,10 +134,10 @@ sub bb2html {
# Also 'normalizes' the first argument in place
sub gtintype {
$_[0] =~ s/[^\d]+//g;
- $_[0] =~ s/^0+//;
+ $_[0] = ('0'x(12-length $_[0])) . $_[0] if length($_[0]) < 12; # pad with zeros to GTIN-12
my $c = shift;
- return undef if $c !~ /^[0-9]{12,13}$/; # only gtin-12 and 13
- $c = ('0'x(13-length $c)) . $c; # pad with zeros
+ return undef if $c !~ /^[0-9]{12,13}$/;
+ $c = "0$c" if length($c) == 12; # pad with another zero for GTIN-13
# calculate check digit according to
# http://www.gs1.org/productssolutions/barcodes/support/check_digit_calculator.html#how
@@ -152,7 +152,7 @@ sub gtintype {
local $_ = $c;
return 'JAN' if /^4[59]/; # prefix code 450-459 & 490-499
return 'UPC' if /^(?:0[01]|0[6-9]|13|75[45])/; # prefix code 000-019 & 060-139 & 754-755
- return undef if /(?:0[2-5]|2|97[789]|9[6-9])/; # some codes we don't want: 020–059 & 200-299 & 977-999
+ return undef if /^(?:0[2-5]|2|97[789]|9[6-9])/; # some codes we don't want: 020–059 & 200-299 & 977-999
return 'EAN'; # let's just call everything else EAN :)
}