| | 1 | == Get compatible components for the build == |
| | 2 | |
| | 3 | === Actors === |
| | 4 | User, Admin |
| | 5 | |
| | 6 | === Scenario === |
| | 7 | 1. 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 | {{{ |
| | 10 | SELECT |
| | 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 |
| | 13 | FROM components c |
| | 14 | JOIN cpu ON cpu.component_id = c.id |
| | 15 | WHERE 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 | ) |
| | 22 | ORDER 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 |
| | 26 | LIMIT COALESCE($limit, 100); |
| | 27 | }}} |
| | 28 | |
| | 29 | {{{ |
| | 30 | SELECT |
| | 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 |
| | 33 | FROM components c |
| | 34 | JOIN motherboard m ON m.component_id = c.id |
| | 35 | WHERE c.type = 'motherboard' |
| | 36 | AND m.socket = $cpuSocket |
| | 37 | AND m.ram_type = $ramType |
| | 38 | AND m.pci_express_slots >= $pciExpressSlotsUsed |
| | 39 | ORDER 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 |
| | 43 | LIMIT COALESCE($limit, 100); |
| | 44 | }}} |
| | 45 | |
| | 46 | {{{ |
| | 47 | SELECT |
| | 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 |
| | 50 | FROM components c |
| | 51 | JOIN cooler co ON co.component_id = c.id |
| | 52 | WHERE c.type = 'cooler' |
| | 53 | AND co.max_tdp_supported >= $cpuTdp |
| | 54 | AND co.height <= $caseCoolerMaxHeight |
| | 55 | ORDER 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 |
| | 59 | LIMIT COALESCE($limit, 100); |
| | 60 | }}} |
| | 61 | |
| | 62 | {{{ |
| | 63 | SELECT |
| | 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 |
| | 66 | FROM components c |
| | 67 | JOIN gpu g ON g.component_id = c.id |
| | 68 | WHERE c.type = 'gpu' |
| | 69 | AND g.length <= $caseGpuMaxLength |
| | 70 | ORDER 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 |
| | 74 | LIMIT COALESCE($limit, 100); |
| | 75 | }}} |
| | 76 | |
| | 77 | {{{ |
| | 78 | SELECT |
| | 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 |
| | 81 | FROM components c |
| | 82 | JOIN memory mem ON mem.component_id = c.id |
| | 83 | WHERE c.type = 'memory' |
| | 84 | AND mem.type = $motherboardRamType |
| | 85 | ORDER 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 |
| | 89 | LIMIT COALESCE($limit, 100); |
| | 90 | }}} |
| | 91 | |
| | 92 | {{{ |
| | 93 | SELECT |
| | 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 |
| | 96 | FROM components c |
| | 97 | JOIN storage s ON s.component_id = c.id |
| | 98 | WHERE c.type = 'storage' |
| | 99 | ORDER 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 |
| | 103 | LIMIT COALESCE($limit, 100); |
| | 104 | }}} |
| | 105 | |
| | 106 | {{{ |
| | 107 | SELECT |
| | 108 | c.id, c.name, c.brand, c.price, c.img_url, c.type, |
| | 109 | pc.cooler_max_height, pc.gpu_max_length |
| | 110 | FROM components c |
| | 111 | JOIN pc_case pc ON pc.component_id = c.id |
| | 112 | WHERE c.type = 'case' |
| | 113 | AND pc.gpu_max_length >= $gpuLength |
| | 114 | AND pc.cooler_max_height >= $coolerHeight |
| | 115 | ORDER 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 |
| | 119 | LIMIT COALESCE($limit, 100); |
| | 120 | }}} |
| | 121 | |
| | 122 | {{{ |
| | 123 | SELECT |
| | 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 |
| | 126 | FROM components c |
| | 127 | JOIN power_supply ps ON ps.component_id = c.id |
| | 128 | WHERE c.type = 'power_supply' |
| | 129 | AND ps.wattage >= ($existingTDP * 1.2) |
| | 130 | ORDER 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 |
| | 134 | LIMIT COALESCE($limit, 100); |
| | 135 | }}} |
| | 136 | |
| | 137 | {{{ |
| | 138 | SELECT |
| | 139 | c.id, c.name, c.brand, c.price, c.img_url, c.type, |
| | 140 | nc.num_ports, nc.speed, nc.interface |
| | 141 | FROM components c |
| | 142 | JOIN network_card nc ON nc.component_id = c.id |
| | 143 | WHERE c.type = 'network_card' |
| | 144 | AND ($pciExpressSlotsUsed + 1) <= $motherboardPciExpressSlots |
| | 145 | ORDER 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 |
| | 149 | LIMIT COALESCE($limit, 100); |
| | 150 | }}} |
| | 151 | |
| | 152 | {{{ |
| | 153 | SELECT |
| | 154 | c.id, c.name, c.brand, c.price, c.img_url, c.type, |
| | 155 | na.wifi_version, na.interface, na.num_antennas |
| | 156 | FROM components c |
| | 157 | JOIN network_adapter na ON na.component_id = c.id |
| | 158 | WHERE c.type = 'network_adapter' |
| | 159 | AND ($pciExpressSlotsUsed + 1) <= $motherboardPciExpressSlots |
| | 160 | ORDER 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 |
| | 164 | LIMIT COALESCE($limit, 100); |
| | 165 | }}} |
| | 166 | |
| | 167 | {{{ |
| | 168 | SELECT |
| | 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 |
| | 171 | FROM components c |
| | 172 | JOIN sound_card sc ON sc.component_id = c.id |
| | 173 | WHERE c.type = 'sound_card' |
| | 174 | AND ($pciExpressSlotsUsed + 1) <= $motherboardPciExpressSlots |
| | 175 | ORDER 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 |
| | 179 | LIMIT COALESCE($limit, 100); |
| | 180 | }}} |