Sfoglia il codice sorgente

chore(core): Remove unnecessary dataloader and script

Will Nahmens 1 settimana fa
parent
commit
1dfd3296c4

+ 0 - 30
packages/core/src/api/resolvers/entity/collection-product-variants-dataloader.ts

@@ -1,30 +0,0 @@
-import { Injectable } from '@nestjs/common';
-import { ID } from '@vendure/common/lib/shared-types';
-
-import { ProductVariantService } from '../../../service/services/product-variant.service';
-import { RequestContext } from '../../common/request-context';
-
-/**
- * DataLoader for batching collection product variant count queries.
- * Prevents N+1 queries when fetching productVariants.totalItems for multiple collections.
- */
-@Injectable()
-export class CollectionProductVariantsDataLoader {
-    constructor(private productVariantService: ProductVariantService) {}
-
-    /**
-     * Creates a batch loader function that fetches variant counts for multiple collections
-     */
-    createLoader(ctx: RequestContext) {
-        const loadCounts = async (collectionIds: readonly ID[]): Promise<number[]> => {
-            const countMap = await this.productVariantService.getVariantCountsByCollectionIds(ctx, [
-                ...collectionIds,
-            ]);
-
-            // Return counts in the same order as input IDs
-            return collectionIds.map(id => countMap.get(id) ?? 0);
-        };
-
-        return loadCounts;
-    }
-}

+ 0 - 99
scripts/benchmark-collection-n1.sh

@@ -1,99 +0,0 @@
-#!/bin/bash
-
-# Collection N+1 Query Benchmark Runner
-# This script makes it easy to run the collection N+1 benchmarks
-
-set -e
-
-# Colors for output
-GREEN='\033[0;32m'
-BLUE='\033[0;34m'
-YELLOW='\033[1;33m'
-NC='\033[0m' # No Color
-
-echo -e "${BLUE}========================================${NC}"
-echo -e "${BLUE}Collection N+1 Query Benchmark${NC}"
-echo -e "${BLUE}========================================${NC}"
-echo ""
-
-# Parse arguments
-MODE=${1:-quick}
-DB=${2:-sqljs}
-
-if [ "$MODE" = "help" ] || [ "$MODE" = "--help" ] || [ "$MODE" = "-h" ]; then
-    echo "Usage: $0 [mode] [database]"
-    echo ""
-    echo "Modes:"
-    echo "  quick  - Fast query count test (default)"
-    echo "  full   - Complete benchmark with performance metrics"
-    echo "  both   - Run both quick and full benchmarks"
-    echo ""
-    echo "Databases:"
-    echo "  sqljs    - SQLite in-memory (default, fastest)"
-    echo "  postgres - PostgreSQL (recommended for production)"
-    echo "  mysql    - MySQL"
-    echo ""
-    echo "Examples:"
-    echo "  $0 quick          # Quick test with SQLite"
-    echo "  $0 full postgres  # Full benchmark with PostgreSQL"
-    echo "  $0 both           # Both tests with SQLite"
-    exit 0
-fi
-
-cd "$(dirname "$0")/../packages/core"
-
-run_quick_test() {
-    echo -e "${GREEN}Running Quick Test...${NC}"
-    echo -e "${YELLOW}Database: $DB${NC}"
-    echo ""
-
-    if [ "$DB" = "sqljs" ]; then
-        npm run e2e collection-n-plus-one-quick.e2e-spec.ts
-    else
-        DB=$DB npm run e2e collection-n-plus-one-quick.e2e-spec.ts
-    fi
-
-    echo ""
-}
-
-run_full_benchmark() {
-    echo -e "${GREEN}Running Full Benchmark...${NC}"
-    echo -e "${YELLOW}Database: $DB${NC}"
-    echo ""
-
-    if [ "$DB" = "sqljs" ]; then
-        npm run bench collection-n-plus-one.bench.ts
-    else
-        DB=$DB npm run bench collection-n-plus-one.bench.ts
-    fi
-
-    echo ""
-}
-
-case "$MODE" in
-    quick)
-        run_quick_test
-        ;;
-    full)
-        run_full_benchmark
-        ;;
-    both)
-        run_quick_test
-        echo -e "${BLUE}----------------------------------------${NC}"
-        run_full_benchmark
-        ;;
-    *)
-        echo -e "${YELLOW}Unknown mode: $MODE${NC}"
-        echo "Use '$0 help' for usage information"
-        exit 1
-        ;;
-esac
-
-echo -e "${GREEN}✓ Benchmark complete${NC}"
-echo ""
-echo -e "Next steps:"
-echo "  1. Record baseline metrics above"
-echo "  2. Implement fix in collection.service.ts or resolver"
-echo "  3. Run benchmark again to validate improvement"
-echo "  4. Target: 0 N+1 queries, <2.0 query efficiency"
-echo ""