diff --git a/app/Data/Collections/CollectionTraitData.php b/app/Data/Collections/CollectionTraitData.php index bcae13d66..0e104cfe8 100644 --- a/app/Data/Collections/CollectionTraitData.php +++ b/app/Data/Collections/CollectionTraitData.php @@ -16,7 +16,6 @@ '/** Use the displayType to infer the actual type. */ value' => 'string | number', '/** Only present for numeric displayTypes. */ valueMin' => '?number', '/** Only present for numeric displayTypes. */ valueMax' => '?number', - 'nftsCount' => 'number', 'nftsPercentage' => 'number', ])] class CollectionTraitData extends Data @@ -27,7 +26,6 @@ public function __construct( public string|float $value, public ?float $valueMin, public ?float $valueMax, - public float $nftsCount, public float $nftsPercentage, ) { } @@ -40,7 +38,6 @@ public static function fromModel(CollectionTrait $trait): self value: self::extractValue($trait), valueMin: $trait['value_min'] ?? null, valueMax: $trait['value_max'] ?? null, - nftsCount: $trait['nfts_count'], nftsPercentage: $trait['nfts_percentage'], ); } diff --git a/app/Data/Web3/Web3CollectionTrait.php b/app/Data/Web3/Web3CollectionTrait.php index f836e79f4..9c75e81d1 100644 --- a/app/Data/Web3/Web3CollectionTrait.php +++ b/app/Data/Web3/Web3CollectionTrait.php @@ -13,7 +13,6 @@ public function __construct( public string $value, public ?float $valueMin, public ?float $valueMax, - public string $nftsCount, public float $nftsPercentage, public TraitDisplayType $displayType, ) { diff --git a/app/Models/CollectionTrait.php b/app/Models/CollectionTrait.php index 68fb1a747..299cb4dcf 100644 --- a/app/Models/CollectionTrait.php +++ b/app/Models/CollectionTrait.php @@ -28,7 +28,6 @@ class CollectionTrait extends Model 'value_min', 'value_max', 'nfts_percentage', - 'nfts_count', ]; protected $casts = [ diff --git a/app/Support/Web3CollectionHandler.php b/app/Support/Web3CollectionHandler.php index 872dcc04d..03b73f7fe 100644 --- a/app/Support/Web3CollectionHandler.php +++ b/app/Support/Web3CollectionHandler.php @@ -26,18 +26,14 @@ public function storeTraits(int $collectionId, Collection $traits): void return [ 'collection_id' => $collectionId, 'name' => $trait->name, - 'value' => $trait->value, 'display_type' => $trait->displayType->value, - 'value_min' => $trait->valueMin, 'value_max' => $trait->valueMax, - - 'nfts_count' => $trait->nftsCount, 'nfts_percentage' => $trait->nftsPercentage, ]; })->toArray(), ['collection_id', 'name', 'value'], - ['display_type', 'value_min', 'value_max', 'nfts_count', 'nfts_percentage']); + ['display_type', 'value_min', 'value_max', 'nfts_percentage']); } } diff --git a/app/Support/Web3NftHandler.php b/app/Support/Web3NftHandler.php index cd86a768a..ef4b70d54 100644 --- a/app/Support/Web3NftHandler.php +++ b/app/Support/Web3NftHandler.php @@ -271,16 +271,13 @@ public function upsertTraits(Collection $nfts, Collection $collectionLookup, Car $trait['normalizedValue'], $trait['displayType']->value, 0, - 0, $now, $now, ]); - $placeholders = $params->map(fn ($_) => '(?, ?, ?, ?, ?, ?, ?, ?)')->join(', '); - $query = sprintf( get_query('nfts.insert_collection_traits'), - $placeholders + $params->map(fn ($_) => '(?, ?, ?, ?, ?, ?, ?)')->join(', ') ); $dbTraits = collect(DB::select($query, $params->flatten()->toArray())); diff --git a/database/factories/CollectionTraitFactory.php b/database/factories/CollectionTraitFactory.php index 001c16f26..67fd71dde 100644 --- a/database/factories/CollectionTraitFactory.php +++ b/database/factories/CollectionTraitFactory.php @@ -43,7 +43,6 @@ public function definition(): array 'value_max' => $valueMax, 'nfts_percentage' => fn () => fake()->randomFloat(3, 0, 100.0), - 'nfts_count' => fn () => random_int(0, 10000), ]; } } diff --git a/database/migrations/2024_02_19_141526_remove_nfts_count_from_collection_traits_table.php b/database/migrations/2024_02_19_141526_remove_nfts_count_from_collection_traits_table.php new file mode 100644 index 000000000..34b337198 --- /dev/null +++ b/database/migrations/2024_02_19_141526_remove_nfts_count_from_collection_traits_table.php @@ -0,0 +1,20 @@ +dropColumn('nfts_count'); + }); + } +}; diff --git a/database/seeders/LiveUserSeeder.php b/database/seeders/LiveUserSeeder.php index bdd628787..f2bb98d26 100644 --- a/database/seeders/LiveUserSeeder.php +++ b/database/seeders/LiveUserSeeder.php @@ -211,7 +211,6 @@ private function ingestCollectionTraitsFixtures(string $fileName): void value: $trait['value'], valueMin: $trait['valueMin'] ?? 0, valueMax: $trait['valueMax'] ?? 0, - nftsCount: $trait['nftsCount'], nftsPercentage: $trait['nftsPercentage'], displayType: TraitDisplayType::from($trait['displayType']), ))->unique(fn ($trait) => '_'.$dbCollection->id.'_'.$trait->name.'_'.$trait->value); diff --git a/database/seeders/TopCollectionsNftsSeeder.php b/database/seeders/TopCollectionsNftsSeeder.php index 03336e9d1..03b6656f2 100644 --- a/database/seeders/TopCollectionsNftsSeeder.php +++ b/database/seeders/TopCollectionsNftsSeeder.php @@ -71,7 +71,6 @@ public function run(): void 'value_max' => $trait['valueMin'], 'value_min' => $trait['valueMax'], 'display_type' => $trait['displayType'], - 'nfts_count' => $trait['nftsCount'], 'nfts_percentage' => $trait['nftsPercentage'], ]); diff --git a/queries/nfts.insert_collection_traits.sql b/queries/nfts.insert_collection_traits.sql index 20ed0ceec..7dfe7813b 100644 --- a/queries/nfts.insert_collection_traits.sql +++ b/queries/nfts.insert_collection_traits.sql @@ -1,9 +1,5 @@ -insert into collection_traits ( - collection_id, name, value, display_type, - nfts_count, nfts_percentage, - created_at, updated_at -) values %s +insert into collection_traits (collection_id, name, value, display_type, nfts_percentage, created_at, updated_at) +values %s on conflict (collection_id, name, value) do update -set nfts_count = (case when excluded.nfts_count > 0 then excluded.nfts_count else collection_traits.nfts_count end), - nfts_percentage = (case when excluded.nfts_percentage > 0 then excluded.nfts_percentage else collection_traits.nfts_percentage end) -returning id, collection_id, name, value \ No newline at end of file +set nfts_percentage = (case when excluded.nfts_percentage > 0 then excluded.nfts_percentage else collection_traits.nfts_percentage end) +returning id, collection_id, name, value diff --git a/resources/js/Tests/Factories/CollectionTraitDataFactory.ts b/resources/js/Tests/Factories/CollectionTraitDataFactory.ts index d56dbd493..628a21476 100644 --- a/resources/js/Tests/Factories/CollectionTraitDataFactory.ts +++ b/resources/js/Tests/Factories/CollectionTraitDataFactory.ts @@ -10,7 +10,6 @@ export default class CollectionTraitDataFactory extends ModelFactory