Add (ai gen)

This commit is contained in:
2023-10-01 22:23:38 +08:00
parent b8fbfcdac2
commit 274e11193d
8 changed files with 664 additions and 4 deletions

View File

@@ -10,6 +10,7 @@
use App\Models\AiWriteup;
use App\Models\Post;
use App\Models\PostCategory;
use App\Models\ShopeeSellerCategory;
use App\Models\ShopeeSellerScrape;
use App\Models\ShopeeSellerScrapedImage;
use Exception;
@@ -96,6 +97,25 @@ public static function handle(ShopeeSellerScrape $shopee_seller_scrape)
$post = Post::create($post_data);
if (! is_null($post)) {
$shopee_seller_scrape->write_counts = $shopee_seller_scrape->write_counts + 1;
$shopee_seller_scrape->last_ai_written_at = now();
$shopee_seller_scrape->save();
$shopee_seller_category = ShopeeSellerCategory::where('seller', $shopee_seller_scrape->seller)->first();
if (is_null($shopee_seller_category))
{
$shopee_seller_category = new ShopeeSellerCategory;
$shopee_seller_category->seller = $shopee_seller_scrape->seller;
$shopee_seller_category->category_id = $shopee_seller_scrape->category_id;
}
$shopee_seller_category->last_ai_written_at = $shopee_seller_scrape->last_ai_written_at;
$shopee_seller_category->write_counts = $shopee_seller_scrape->write_counts;
$shopee_seller_category->save();
PostCategory::create([
'post_id' => $post->id,
'category_id' => $shopee_seller_scrape->category->id,

View File

@@ -77,7 +77,6 @@ public static function handle(string $seller, string $country_iso, Category $cat
$shopee_seller_scrape->epoch = $epoch;
$shopee_seller_scrape->filename = $filename;
$shopee_seller_scrape->category_id = $category->id;
$shopee_seller_scrape->last_ai_written_at = now();
if ($shopee_seller_scrape->save()) {
return (object) compact('seller_shop_task', 'product_task', 'shopee_seller_scrape');