Changes between Initial Version and Version 1 of AddComponentToBuild


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

--

Legend:

Unmodified
Added
Removed
Modified
  • AddComponentToBuild

    v1 v1  
     1== Add component to build ==
     2
     3=== Actors ===
     4User, Admin
     5
     6=== Scenario ===
     71. In the forge, after the user chooses the desired compatible component they click on "ADD"
     82. The server adds the component to the build
     9
     10{{{
     11BEGIN;
     12
     13SELECT *
     14FROM build
     15WHERE id = $buildId
     16  AND user_id = $userId
     17LIMIT 1;
     18
     19SELECT *
     20FROM build_component
     21WHERE build_id = $buildId
     22  AND component_id = $componentId
     23LIMIT 1;
     24
     25INSERT INTO build_component (build_id, component_id)
     26VALUES ($buildId, $componentId);
     27
     28SELECT c.price
     29FROM build_component bc
     30JOIN components c ON c.id = bc.component_id
     31WHERE bc.build_id = $buildId;
     32
     33UPDATE build
     34SET total_price = (
     35  SELECT COALESCE(ROUND(SUM(c.price), 2), 0)
     36  FROM build_component bc
     37  JOIN components c ON c.id = bc.component_id
     38  WHERE bc.build_id = $buildId
     39)
     40WHERE id = $buildId;
     41
     42COMMIT;
     43}}}