Changes between Initial Version and Version 1 of GetCompatibleComponents


Ignore:
Timestamp:
12/29/25 01:00:47 (23 hours ago)
Author:
233051
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GetCompatibleComponents

    v1 v1  
     1== Get compatible components for the build ==
     2
     3=== Actors ===
     4User, Admin
     5
     6=== Scenario ===
     71. In the forge, the user clicks on the type of component they want to add, and depending on what other components are already in the build only compatible ones will be displayed
     8
     9{{{
     10SELECT
     11  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     12  cpu.socket, cpu.cores, cpu.threads, cpu.base_clock, cpu.boost_clock, cpu.tdp
     13FROM components c
     14JOIN cpu ON cpu.component_id = c.id
     15WHERE c.type = 'cpu'
     16  AND cpu.socket = $motherboardSocket
     17  AND cpu.tdp <= $coolerMaxTdpSupported
     18  AND EXISTS (
     19     SELECT 1 FROM cooler_cpu_sockets s
     20     WHERE s.cooler_id = $coolerId AND s.socket = cpu.socket
     21  )
     22ORDER BY
     23  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     24  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     25  c.price DESC
     26LIMIT COALESCE($limit, 100);
     27}}}
     28
     29{{{
     30SELECT
     31  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     32  m.socket, m.chipset, m.form_factor, m.ram_type, m.num_ram_slots, m.max_ram_capacity, m.pci_express_slots
     33FROM components c
     34JOIN motherboard m ON m.component_id = c.id
     35WHERE c.type = 'motherboard'
     36  AND m.socket = $cpuSocket
     37  AND m.ram_type = $ramType
     38  AND m.pci_express_slots >= $pciExpressSlotsUsed
     39ORDER BY
     40  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     41  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     42  c.price DESC
     43LIMIT COALESCE($limit, 100);
     44}}}
     45
     46{{{
     47SELECT
     48  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     49  co.type AS cooler_type, co.height, co.max_tdp_supported
     50FROM components c
     51JOIN cooler co ON co.component_id = c.id
     52WHERE c.type = 'cooler'
     53  AND co.max_tdp_supported >= $cpuTdp
     54  AND co.height <= $caseCoolerMaxHeight
     55ORDER BY
     56  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     57  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     58  c.price DESC
     59LIMIT COALESCE($limit, 100);
     60}}}
     61
     62{{{
     63SELECT
     64  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     65  g.vram, g.tdp, g.base_clock, g.boost_clock, g.chipset, g.length
     66FROM components c
     67JOIN gpu g ON g.component_id = c.id
     68WHERE c.type = 'gpu'
     69  AND g.length <= $caseGpuMaxLength
     70ORDER BY
     71  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     72  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     73  c.price DESC
     74LIMIT COALESCE($limit, 100);
     75}}}
     76
     77{{{
     78SELECT
     79  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     80  mem.type AS memory_type, mem.speed, mem.capacity, mem.modules
     81FROM components c
     82JOIN memory mem ON mem.component_id = c.id
     83WHERE c.type = 'memory'
     84  AND mem.type = $motherboardRamType
     85ORDER BY
     86  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     87  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     88  c.price DESC
     89LIMIT COALESCE($limit, 100);
     90}}}
     91
     92{{{
     93SELECT
     94  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     95  s.type AS storage_type, s.capacity, s.form_factor
     96FROM components c
     97JOIN storage s ON s.component_id = c.id
     98WHERE c.type = 'storage'
     99ORDER BY
     100  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     101  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     102  c.price DESC
     103LIMIT COALESCE($limit, 100);
     104}}}
     105
     106{{{
     107SELECT
     108  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     109  pc.cooler_max_height, pc.gpu_max_length
     110FROM components c
     111JOIN pc_case pc ON pc.component_id = c.id
     112WHERE c.type = 'case'
     113  AND pc.gpu_max_length >= $gpuLength
     114  AND pc.cooler_max_height >= $coolerHeight
     115ORDER BY
     116  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     117  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     118  c.price DESC
     119LIMIT COALESCE($limit, 100);
     120}}}
     121
     122{{{
     123SELECT
     124  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     125  ps.type AS psu_type, ps.wattage, ps.form_factor
     126FROM components c
     127JOIN power_supply ps ON ps.component_id = c.id
     128WHERE c.type = 'power_supply'
     129  AND ps.wattage >= ($existingTDP * 1.2)
     130ORDER BY
     131  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     132  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     133  c.price DESC
     134LIMIT COALESCE($limit, 100);
     135}}}
     136
     137{{{
     138SELECT
     139  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     140  nc.num_ports, nc.speed, nc.interface
     141FROM components c
     142JOIN network_card nc ON nc.component_id = c.id
     143WHERE c.type = 'network_card'
     144  AND ($pciExpressSlotsUsed + 1) <= $motherboardPciExpressSlots
     145ORDER BY
     146  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     147  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     148  c.price DESC
     149LIMIT COALESCE($limit, 100);
     150}}}
     151
     152{{{
     153SELECT
     154  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     155  na.wifi_version, na.interface, na.num_antennas
     156FROM components c
     157JOIN network_adapter na ON na.component_id = c.id
     158WHERE c.type = 'network_adapter'
     159  AND ($pciExpressSlotsUsed + 1) <= $motherboardPciExpressSlots
     160ORDER BY
     161  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     162  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     163  c.price DESC
     164LIMIT COALESCE($limit, 100);
     165}}}
     166
     167{{{
     168SELECT
     169  c.id, c.name, c.brand, c.price, c.img_url, c.type,
     170  sc.sample_rate, sc.bit_depth, sc.chipset, sc.interface, sc.channel
     171FROM components c
     172JOIN sound_card sc ON sc.component_id = c.id
     173WHERE c.type = 'sound_card'
     174  AND ($pciExpressSlotsUsed + 1) <= $motherboardPciExpressSlots
     175ORDER BY
     176  CASE WHEN $sort = 'price_asc'  THEN c.price END ASC,
     177  CASE WHEN $sort = 'price_desc' THEN c.price END DESC,
     178  c.price DESC
     179LIMIT COALESCE($limit, 100);
     180}}}