Skip to content

Commit

Permalink
Merge pull request #3520 from coopcycle/typesense-bundle
Browse files Browse the repository at this point in the history
Use acseo/typesense-bundle
  • Loading branch information
alexsegura authored Jan 9, 2023
2 parents 9ae2dd4 + 6eebea5 commit 7fada3e
Show file tree
Hide file tree
Showing 20 changed files with 287 additions and 639 deletions.
1 change: 1 addition & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function registerBundles()
new M6Web\Bundle\DaemonBundle\M6WebDaemonBundle(),
new Oneup\FlysystemBundle\OneupFlysystemBundle(),
new Kreait\Firebase\Symfony\Bundle\FirebaseBundle(),
new ACSEO\TypesenseBundle\ACSEOTypesenseBundle(),
new AppBundle\AppBundle(),
];

Expand Down
67 changes: 65 additions & 2 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ parameters:
en_boite_le_plat_enabled: '%env(bool:EN_BOITE_LE_PLAT_ENABLED)%'
nonprofits_enabled: '%env(bool:NONPROFITS_ENABLED)%'
dv4cul_enabled: '%env(bool:DV4CUL_ENABLED)%'
typesense_schemas_dir: "%kernel.project_dir%/src/Resources/config/typesense/schemas"
typesense_shops_collection_name: "%database_name%_shops"
dabba_enabled: '%env(bool:DABBA_ENABLED)%'
dabba_base_url: '%env(DABBA_BASE_URL)%'
dabba_client_id: '%env(DABBA_CLIENT_ID)%'
dabba_client_secret: '%env(DABBA_CLIENT_SECRET)%'
typesense_shops_collection_name: "shops"
typesense_products_collection_name: "products"

services:
# For some cache pools, want *STABLE* cache keys between deploys.
Expand Down Expand Up @@ -956,3 +956,66 @@ doctrine_migrations:
table_name: migration_versions
version_column_name: version
executed_at_column_name: executed_at

acseo_typesense:
typesense:
url: 'http://%env(TYPESENSE_HOST)%:%env(TYPESENSE_PORT)%'
key: '%env(TYPESENSE_API_KEY)%'
collection_prefix: '%database_name%_'
collections:
products:
entity: 'AppBundle\Entity\Sylius\Product'
collection_name: '%typesense_products_collection_name%'
fields:
id:
name: id
type: primary
sortable_id:
entity_attribute: id
name: sortable_id
type: int32
name:
name: name
type: string
default_sorting_field: sortable_id
finders:
products_autocomplete:
finder_parameters:
query_by: title
limit: 10
prefix: true
num_typos: 1
drop_tokens_threshold: 1
shops:
entity: 'AppBundle\Entity\LocalBusiness'
collection_name: '%typesense_shops_collection_name%'
fields:
id:
name: id
type: primary
sortable_id:
entity_attribute: id
name: sortable_id
type: int32
name:
name: name
type: string
type:
name: type
type: string
facet: true
entity_attribute: shopType
cuisine:
name: cuisine
type: string[]
facet: true
entity_attribute: shopCuisines
category:
name: category
type: string[]
facet: true
entity_attribute: shopCategories
enabled:
name: enabled
type: bool
default_sorting_field: sortable_id
3 changes: 2 additions & 1 deletion app/config/config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ imports:
parameters:
tile38_fleet_key: '%database_name%_test:fleet'
tile38_doorstep_chan_namespace: '%database_name%_test'
typesense_shops_collection_name: "%database_name%_shops_test"
typesense_shops_collection_name: "shops_test"
typesense_products_collection_name: "products_test"

framework:
test: ~
Expand Down
23 changes: 3 additions & 20 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ services:
Hashids\Hashids $hashids8: '@hashids.8'
Hashids\Hashids $hashids12: '@hashids.12'
BenjaminFavre\OAuthHttpClient\OAuthHttpClient $woopitClient: '@woopit.oauth_http_client'
ACSEO\TypesenseBundle\Finder\CollectionFinderInterface $typesenseShopsFinder: '@typesense.finder.shops'
ACSEO\TypesenseBundle\Manager\CollectionManager: '@typesense.collection_manager'
ACSEO\TypesenseBundle\Manager\DocumentManager: '@typesense.document_manager'

AppBundle\Routing\FoodtechEnabledAwareLoader:
arguments:
Expand Down Expand Up @@ -677,7 +680,6 @@ services:

AppBundle\Doctrine\EventSubscriber\ShopsEventsForTypesenseSubscriber:
tags:
- { name: monolog.logger }
- { name: doctrine.event_subscriber }

AppBundle\Action\Settings:
Expand Down Expand Up @@ -1084,15 +1086,6 @@ services:
arguments:
$productOptionValueRepository: '@sylius.repository.product_option_value'

Typesense\Client:
arguments:
- api_key: '%env(TYPESENSE_API_KEY)%'
nodes:
- host: '%env(TYPESENSE_HOST)%'
port: '%env(TYPESENSE_PORT)%'
protocol: 'http'
connection_timeout_seconds: 2

Psonic\Client:
arguments:
- '%env(SONIC_HOST)%'
Expand Down Expand Up @@ -1204,16 +1197,6 @@ services:
arguments:
$locale: '%env(COOPCYCLE_LOCALE)%'

AppBundle\Typesense\ShopsClient:
arguments:
$collectionName: '%typesense_shops_collection_name%'

AppBundle\Typesense\CollectionManager:
arguments:
$schemasDir: '%typesense_schemas_dir%'
$collections:
shops: "%typesense_shops_collection_name%"

hashids.8:
class: Hashids\Hashids
arguments: ['%secret%', 8]
Expand Down
17 changes: 0 additions & 17 deletions app/config/services/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,6 @@ services:
tags:
- { name: 'console.command', command: 'coopcycle:avatars:regenerate' }

AppBundle\Command\Typesense\CreateCollectionCommand:
tags:
- { name: 'console.command', command: 'typesense:collection:create' }

AppBundle\Command\Typesense\DeleteCollectionCommand:
tags:
- { name: 'console.command', command: 'typesense:collection:delete' }

AppBundle\Command\Typesense\IndexShopsCommand:
tags:
- { name: 'console.command', command: 'typesense:shops:index' }

# used to create all collections in a test environment
AppBundle\Command\Typesense\CreateAllCollectionsCommand:
tags:
- { name: 'console.command', command: 'typesense:collections:create' }

AppBundle\Command\WoopitSubscriptionsCommand:
tags:
- { name: 'console.command', command: 'woopit:subscriptions:create' }
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@
"benjaminfavre/oauth2-http-client": "^1.0",
"sylius/calendar": "^0.3",
"twig/markdown-extra": "^3.4",
"league/commonmark": "^2.3"
"league/commonmark": "^2.3",
"acseo/typesense-bundle": "dev-fix-indexer"
},
"require-dev": {
"symfony/phpunit-bridge": "^5.0",
Expand All @@ -160,6 +161,10 @@
{
"type": "vcs",
"url": "[email protected]:rkeet/behatch-contexts.git"
},
{
"type": "vcs",
"url": "https://github.com/alexsegura/TypesenseBundle"
}
],
"scripts": {
Expand Down
136 changes: 134 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions features/authentication.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Feature: Authenticate

@debug
Scenario: Login success
Given the user is loaded:
| email | bob@coopcycle.org |
Expand Down
Loading

0 comments on commit 7fada3e

Please sign in to comment.