Skip to content

Commit

Permalink
Merge branch 'development' of github.com:bakaphp/kanvas-ecosystem-api…
Browse files Browse the repository at this point in the history
… into integration-status-history
  • Loading branch information
arfenis committed Sep 17, 2024
2 parents e8ab3ea + b6cc221 commit 4392e50
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 51 deletions.
30 changes: 30 additions & 0 deletions app/GraphQL/Social/Builders/Messages/MessageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

namespace App\GraphQL\Social\Builders\Messages;

use Algolia\AlgoliaSearch\SearchClient;
use GraphQL\Type\Definition\ResolveInfo;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;
use Kanvas\Apps\Models\Apps;
use Kanvas\Social\Enums\AppEnum;
use Kanvas\Social\Messages\Models\Message;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;

Expand Down Expand Up @@ -57,4 +60,31 @@ public function getGroupByDate(
END as additional_field')
);
}

public function searchSuggestions(
mixed $root,
array $args,
GraphQLContext $context,
ResolveInfo $resolveInfo
): array {
$client = SearchClient::create(
config('scout.algolia.id'),
config('scout.algolia.secret')
);

$app = app(Apps::class);
$suggestionIndex = AppEnum::MESSAGE_SEARCH_SUGGESTION_INDEX->value;
if (! $app->get($suggestionIndex)) {
return ['error' => 'No index for message suggestion configure in your app'];
}

$index = $client->initIndex($app->get($suggestionIndex));

$results = $index->search($args['search'], [
'hitsPerPage' => 15,
'attributesToRetrieve' => ['name', 'description'],
]);

return $results['hits'];
}
}
60 changes: 30 additions & 30 deletions composer.lock

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products_types', function (Blueprint $table) {
// Drop the existing unique constraint on companies_id and slug
$table->dropUnique(['companies_id', 'slug']);

// Add the new unique constraint with apps_id included
$table->unique(['apps_id', 'companies_id', 'slug']);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products_types', function (Blueprint $table) {
// Drop the unique constraint with apps_id
$table->dropUnique(['apps_id', 'companies_id', 'slug']);

// Reinstate the original unique constraint on companies_id and slug
$table->unique(['companies_id', 'slug']);
});
}
};
14 changes: 2 additions & 12 deletions docker-compose.development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ services:
dockerfile: development.Dockerfile
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "8000:8000"
command:
- "sh"
- "-c"
Expand Down Expand Up @@ -59,18 +61,6 @@ services:
<<: *common-queue-settings
container_name: queue3

queue4:
<<: *common-queue-settings
container_name: queue4

queue5:
<<: *common-queue-settings
container_name: queue5

queue6:
<<: *common-queue-settings
container_name: queue6

batch-logger-queue:
<<: *common-queue-settings
container_name: batch-logger-queue
Expand Down
2 changes: 1 addition & 1 deletion graphql/schemas/Ecosystem/Filesystem/fileSystem.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Filesystem {
url: String!
type: String
size: Float!
field_name: String!
field_name: String
attributes: JSON
}

Expand Down
20 changes: 19 additions & 1 deletion graphql/schemas/Social/message.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ extend type Query @guard {
"reactions_count"
"comments_count"
"total_liked"
"total_children"
"total_disliked"
"total_saved"
"total_view"
Expand All @@ -194,7 +195,20 @@ extend type Query @guard {
)
hasAppModuleMessage: _
@whereHasConditions(columns: ["entity_id", "system_modules"])
orderBy: _ @orderBy(columns: ["created_at", "updated_at", "id"])
orderBy: _
@orderBy(
columns: [
"created_at"
"updated_at"
"id"
"total_view"
"total_liked"
"total_shared"
"total_saved"
"total_children"
"total_disliked"
]
)
search: String @search
): [Message!]!
@paginate(
Expand Down Expand Up @@ -274,4 +288,8 @@ extend type Query @guard {
builder: "App\\GraphQL\\Social\\Builders\\Messages\\MessageBuilder@getGroupByDate"
scopes: ["fromApp", "notDeleted"]
)
messageSearchSuggestions(search: String): Mixed!
@field(
resolver: "App\\GraphQL\\Social\\Builders\\Messages\\MessageBuilder@searchSuggestions"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function saveProduct(Products $product, StatusEnum $status, ?Channels $ch
'body_html' => $product->description,
'product_type' => $product->productsTypes?->name ?? 'default',
'vendor' => 'default' , //$product->categ->name , setup vendor as a attribute and add a wy to look for a attribute $product->attribute('vendor')
'status' => $status->value,
'status' => $product->hasPrice($this->warehouses, $channel) ? $status->value : StatusEnum::ARCHIVED->value,
'published_scope' => 'web',
];

Expand Down Expand Up @@ -90,7 +90,7 @@ public function saveProduct(Products $product, StatusEnum $status, ?Channels $ch
*/
public function mapVariant(Variants $variant, ?Channels $channel = null): array
{
$warehouseInfo = $variant->variantWarehouses()->where('warehouses_id', $this->warehouses->getId());
$warehouseInfo = $variant->variantWarehouses()->where('warehouses_id', $this->warehouses->getId())->first();

if ($channel) {
$channelInfo = $variant->variantChannels()->where('channels_id', $channel->getId())->first();
Expand Down Expand Up @@ -127,7 +127,7 @@ public function mapVariant(Variants $variant, ?Channels $channel = null): array
return $shopifyVariantInfo;
}

public function saveVariant(Variants $variant, Channels $channel = null): array
public function saveVariant(Variants $variant, ?Channels $channel = null): array
{
$shopifyProductVariantId = $variant->getShopifyId($this->warehouses->regions);
$shopifyVariantMetafieldService = new ShopifyVariantMetafieldService($this->app, $this->company, $this->warehouses->regions, $variant);
Expand Down Expand Up @@ -157,7 +157,7 @@ public function saveVariant(Variants $variant, Channels $channel = null): array
return $response;
}

public function setStock(Variants $variant, Channels $channel, bool $isAdjustment = false): int
public function setStock(Variants $variant, ?Channels $channel = null, bool $isAdjustment = false): int
{
$shopifyVariant = $this->shopifySdk->ProductVariant($variant->getShopifyId($this->warehouses->regions));

Expand Down Expand Up @@ -218,12 +218,12 @@ public function attachToCollection(Products $product, string $collectionId): voi

$collectData = [
'collection_id' => $collectionId,
'product_id' => $shopifyProductId
'product_id' => $shopifyProductId,
];
$collects = $this->shopifySdk->Collect->get([
'collection_id' => $collectionId,
'product_id' => $shopifyProductId,
'limit' => 1
'limit' => 1,
]);
if ($collects) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function execute(): array
$dto = new PeopleSubscriptionDTO(
app: $app,
people: $people,
subscription_type: $subscriptions['plan']['nickname'],
subscription_type: $subscriptions['plan']['nickname'] ?? $subscriptions['plan']['product'],
status: '1',
first_date: date('Y-m-d H:i:s', $subscriptions['created']),
start_date: date('Y-m-d H:i:s', $subscriptions['current_period_start']),
Expand Down
Loading

0 comments on commit 4392e50

Please sign in to comment.