Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install typesense and update index structure #349

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_CALLBACK_URL=http://novapackages.test/login/github/callback

SCOUT_DRIVER=algolia
ALGOLIA_APP_ID=
ALGOLIA_SECRET=
SCOUT_DRIVER=typesense
SCOUT_PREFIX=
TYPESENSE_API_KEY=
TYPESENSE_HOST=
TYPESENSE_PORT=
TYPESENSE_PROTOCOL=

HONEYBADGER_API_KEY=

Expand Down
14 changes: 13 additions & 1 deletion app/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,26 @@ public function toSearchableArray()
// Temporarily truncate to prevent algolia from throwing a size exceeded exception
$packageAttributes['readme'] = substr($packageAttributes['readme'], 0, 500);
$packageAttributes['instructions'] = substr($packageAttributes['instructions'], 0, 500);
$packageAttributes['created_at'] = $this->created_at->timestamp;

Arr::forget($packageAttributes, $this->excludeFromSearchIndex);

// Add tags so we can filter them
// @todo Make sure this is updated when tags are updated
$packageAttributes['_tags'] = $this->tags->pluck('slug')->toArray();

return $packageAttributes;
return [
'id' => (string) $packageAttributes['id'],
'name' => (string) ($packageAttributes['name'] ?? ''),
'url' => (string) ($packageAttributes['url'] ?? ''),
'instructions' => (string) ($packageAttributes['instructions'] ?? ''),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is any better, but potentially worth considering 🤷🏻

Suggested change
'instructions' => (string) ($packageAttributes['instructions'] ?? ''),
'instructions' => data_get($packageAttributes, 'instructions', ''),

'composer_name' => (string) ($packageAttributes['composer_name'] ?? ''),
'repo_url' => (string) ($packageAttributes['repo_url'] ?? ''),
'readme' => (string) ($packageAttributes['readme'] ?? ''),
'abstract' => (string) ($packageAttributes['abstract'] ?? ''),
'_tags' => ($packageAttributes['_tags'] ?? []),
'created_at' => $packageAttributes['created_at'],
];
}

protected static function booted()
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"laravel/helpers": "^1.6",
"laravel/horizon": "^5.12",
"laravel/passport": "^11.5",
"laravel/scout": "^9.8",
"laravel/scout": "^v10.7.0",
"laravel/slack-notification-channel": "^2.5",
"laravel/socialite": "^5.6",
"laravel/telescope": "^4.12",
Expand All @@ -35,6 +35,7 @@
"spatie/laravel-sitemap": "^6.2",
"stil/gd-text": "^1.1",
"tightenco/ziggy": "^2.0",
"typesense/typesense-php": "^4.9",
"willvincent/laravel-rateable": "^3.1"
},
"require-dev": {
Expand Down
Loading
Loading