Changes between Version 1 and Version 2 of PricetoPerformance
- Timestamp:
- 01/29/26 03:50:23 (10 days ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PricetoPerformance
v1 v2 9 9 10 10 {{{ 11 CREATE OR REPLACE FUNCTION get_report_price_to_performance() 12 RETURNS TABLE ( 13 build_name TEXT, 14 cpu_model TEXT, 15 gpu_model TEXT, 16 total_price NUMERIC, 17 performance_score NUMERIC, 18 price_to_performance_index NUMERIC 19 ) 20 LANGUAGE sql 21 AS $$ 11 22 WITH cpu_per_build AS ( 12 SELECT 23 SELECT 13 24 b.id AS build_id, 14 25 c.name AS cpu_model, … … 16 27 cpu.base_clock 17 28 FROM build b 18 JOIN build_component bc ON b.id = bc.build_id19 JOIN components c ON bc.component_id = c.id20 JOIN cpu ON c.id = cpu.component_id21 WHERE c.type = 'CPU'29 JOIN build_component bc ON b.id = bc.build_id 30 JOIN components c ON bc.component_id = c.id 31 JOIN cpu ON c.id = cpu.component_id 32 WHERE LOWER(c.type) = LOWER('CPU') 22 33 ), 23 gpu_per_build AS ( 24 SELECT 25 b.id AS build_id, 26 c.name AS gpu_model, 27 gpu.vram 28 FROM build b 29 JOIN build_component bc ON b.id = bc.build_id 30 JOIN components c ON bc.component_id = c.id 31 JOIN gpu ON c.id = gpu.component_id 32 WHERE c.type = 'GPU' 33 ) 34 35 SELECT 34 gpu_per_build AS ( 35 SELECT 36 b.id AS build_id, 37 c.name AS gpu_model, 38 gpu.vram 39 FROM build b 40 JOIN build_component bc ON b.id = bc.build_id 41 JOIN components c ON bc.component_id = c.id 42 JOIN gpu ON c.id = gpu.component_id 43 WHERE LOWER(c.type) = LOWER('GPU') 44 ) 45 SELECT 36 46 b.name AS build_name, 37 47 cpu.cpu_model, … … 40 50 (cpu.cores * cpu.base_clock + gpu.vram * 100) AS performance_score, 41 51 ROUND( 42 (cpu.cores * cpu.base_clock + gpu.vram * 100), 43 4 52 CAST( 53 (cpu.cores * cpu.base_clock + gpu.vram * 100) / NULLIF(b.total_price, 0) 54 AS numeric), 55 4 44 56 ) AS price_to_performance_index 45 57 FROM build b 46 JOIN cpu_per_build cpu ON b.id = cpu.build_id47 JOIN gpu_per_build gpu ON b.id = gpu.build_id58 JOIN cpu_per_build cpu ON b.id = cpu.build_id 59 JOIN gpu_per_build gpu ON b.id = gpu.build_id 48 60 WHERE b.total_price > 0 49 61 ORDER BY price_to_performance_index DESC 50 62 LIMIT 20; 63 $$; 51 64 }}} 52 65
