chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
routesearch: abandon higher granuarities when tables become full
[ypp-sc-tools.main.git]
/
yarrg
/
commod-email-processor
diff --git
a/yarrg/commod-email-processor
b/yarrg/commod-email-processor
index 0c16cd196f8e6f53268c6003a9015f8e33f8977e..1cff462cda1c67d451ee8064b9ac952e8e096cae 100755
(executable)
--- a/
yarrg/commod-email-processor
+++ b/
yarrg/commod-email-processor
@@
-39,7
+39,7
@@
BEGIN {
use Commods;
use CommodsDatabase;
use Commods;
use CommodsDatabase;
-set
locale(LC_CTYPE, "en_GB.UTF-8"
);
+set
_ctype_utf8(
);
my $parser= new MIME::Parser;
our $entity;
my $parser= new MIME::Parser;
our $entity;
@@
-123,33
+123,38
@@
sub main () {
$islandid, $mid,
map { $md{$_} } (qw(timestamp clientspec serverspec)));
$islandid, $mid,
map { $md{$_} } (qw(timestamp clientspec serverspec)));
- my (%sth, %sub_cs, %cache_cs, %sth_insert);
+ my (%sth, %sub_cs, %cache_cs, %sth_insert
, %sth_lookup
);
$sth_insert{'stall'}= $dbh->prepare(
"INSERT OR IGNORE
INTO stalls
(islandid, stallname) VALUES ($islandid, ?)
");
$sth_insert{'stall'}= $dbh->prepare(
"INSERT OR IGNORE
INTO stalls
(islandid, stallname) VALUES ($islandid, ?)
");
- $sth_insert{'commods'}= $dbh->prepare(
+ $sth_lookup{'stall'}= $dbh->prepare(
+ "SELECT stallid FROM stalls
+ WHERE islandid == $islandid AND stallname == ?
+ ");
+ $sth_insert{'commod'}= $dbh->prepare(
"INSERT OR IGNORE
INTO commods
(commodname) VALUES (?)
");
"INSERT OR IGNORE
INTO commods
(commodname) VALUES (?)
");
+ $sth_lookup{'commod'}= $dbh->prepare(
+ "SELECT commodid FROM commods
+ WHERE commodname == ?
+ ");
foreach my $cs (qw(stall commod)) {
foreach my $cs (qw(stall commod)) {
- my $sth_lookup= $dbh->prepare(
- "SELECT ${cs}id FROM ${cs}s WHERE ${cs}name == ?;
- ");
$sub_cs{$cs}= sub {
my ($name)= @_;
my $r= $cache_cs{$cs}{$name};
return $r if defined $r;
$sub_cs{$cs}= sub {
my ($name)= @_;
my $r= $cache_cs{$cs}{$name};
return $r if defined $r;
- $sth_lookup->execute($name) or die;
- ($r)= $sth_lookup->fetchrow_array();
+ $sth_lookup
{$cs}
->execute($name) or die;
+ ($r)= $sth_lookup
{$cs}
->fetchrow_array();
if (!defined $r) {
$sth_insert{$cs}->execute($name);
if (!defined $r) {
$sth_insert{$cs}->execute($name);
- $sth_lookup->execute($name) or die;
- ($r)= $sth_lookup->fetchrow_array();
+ $sth_lookup
{$cs}
->execute($name) or die;
+ ($r)= $sth_lookup
{$cs}
->fetchrow_array();
die unless defined $r;
}
$cache_cs{$cs}{$name}= $r;
die unless defined $r;
}
$cache_cs{$cs}{$name}= $r;