added search on supplier listings

This commit is contained in:
Thomas Bloor 2019-09-09 18:03:08 +01:00
parent eabc4e04fb
commit 653f495a70
No known key found for this signature in database
GPG key ID: 4657C7EBE42CC5CC
3 changed files with 31 additions and 0 deletions

View file

@ -59,6 +59,16 @@ To import ward data, get the ward data csv and then run the following command:
--args '[ "/path/to/ward/csv" ]'
```
# Setting up Entity Postcodes
Assuming you have imported codepoint open, then to properly assign all
postcodes:
```shell script
./script/pear-local_loop minion job \
--enqueue entity_postcode_lookup
```
## Example PostgreSQL setup
```

View file

@ -64,6 +64,7 @@ sub post_lcc_suppliers {
$v->optional('page')->number;
$v->optional('sort_by');
$v->optional('sort_dir');
$v->optional('search');
my $order_by = [
{ -asc => 'organisation.name' },
@ -85,6 +86,12 @@ sub post_lcc_suppliers {
my $lcc_suppliers = $c->schema->resultset('Entity')->search(
{
'sales.buyer_id' => $user->entity->id,
( $v->param('search') ? (
'-or' => [
{ 'organisation.name' => { 'like' => $v->param('search') . '%' } },
{ 'organisation.postcode' => { 'like' => $v->param('search') . '%' } },
]
) : () ),
},
{
join => [ 'sales', 'organisation' ],

View file

@ -23,4 +23,18 @@ SELECT "value",
FROM "transactions"
/);
__PACKAGE__->belongs_to(
"buyer",
"Pear::LocalLoop::Schema::Result::Entity",
{ id => "buyer_id" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
__PACKAGE__->belongs_to(
"seller",
"Pear::LocalLoop::Schema::Result::Entity",
{ id => "seller_id" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
1;