fulfillRequest(): basic implementation.
First attempt at implementing fulfillRequest() method. It seems that request_id was incorrectly missing from the fulfillment table.
This commit is contained in:
parent
84f81b4dd3
commit
aff5e66786
2 changed files with 19 additions and 0 deletions
|
@ -579,6 +579,22 @@ sub fufillRequest($$) {
|
|||
|
||||
my $requestId = $self->getRequest($supporterId, $params->{requestType});
|
||||
return undef if not defined $requestId;
|
||||
|
||||
my $fufillLookupSql = "SELECT * FROM fulfillment WHERE request_id = " .
|
||||
$self->dbh->quote($requestId, 'SQL_INTEGER');
|
||||
|
||||
my $fufillRecord = $self->dbh()->selectall_hashref($fufillLookupSql, "request_id");
|
||||
if (not defined $fufillRecord and not defined $fufillRecord->{$requestId}) {
|
||||
$self->_beginWork;
|
||||
my $sth->prepare("INSERT INTO fulfillment(request_id, who, how, date) " .
|
||||
"VALUES(? , ? , ? , date('now');");
|
||||
|
||||
$sth->execute($requestId, $params->{who}, $params->{how});
|
||||
$sth->finish;
|
||||
$self->_commit;
|
||||
$fufillRecord = $self->dbh()->selectall_hashref($fufillLookupSql, "request_id");
|
||||
}
|
||||
return $fufillRecord->{$requestId};
|
||||
}
|
||||
######################################################################
|
||||
|
||||
|
|
|
@ -36,11 +36,14 @@ DROP TABLE IF EXISTS "fulfillment";
|
|||
|
||||
CREATE TABLE "fulfillment" (
|
||||
"id" integer NOT NULL PRIMARY KEY,
|
||||
"request_id" integer NOT NULL,
|
||||
"date" TEXT NOT NULL,
|
||||
"who" varchar(300) NOT NULL,
|
||||
"how" TEXT
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX fulfillment__one_fulfillment_per_request ON fulfillment(request_id);
|
||||
|
||||
DROP TABLE IF EXISTS "request_type";
|
||||
|
||||
CREATE TABLE "request_type" (
|
||||
|
|
Loading…
Reference in a new issue