diff --git a/sql/import-config.sql b/sql/import-config.sql index 8401ee5..fe5843d 100644 --- a/sql/import-config.sql +++ b/sql/import-config.sql @@ -7,8 +7,8 @@ begin description text not null, image text not null, claimAmount integer not null, - basePrice integer not null, completionTimeInMins integer not null, + basePrice integer not null, tier_1_price integer not null, tier_1_claimboost integer not null, tier_2_price integer not null, @@ -33,7 +33,13 @@ begin perform download_sheets(); - copy storeItems from '/tmp/storeItems.csv' with (delimiter ',', format csv, header true); + --- For some reason if you don't explicitly set it, it just copies it in a weird order + copy storeItems( + id, name, description, image, claimAmount, completionTimeInMins, basePrice, + tier_1_price, tier_1_claimboost, tier_2_price, tier_2_claimboost, + tier_3_price, tier_3_claimboost, tier_4_price, tier_4_claimboost, + tier_5_price, tier_5_claimboost + ) from '/tmp/storeItems.csv' with (delimiter ',', format csv, header true); copy stakingSources from '/tmp/stakingSources.csv' (delimiter ',', format csv, header true); copy gameConstants from '/tmp/gameConstants.csv' with (delimiter ',', format csv, header true); diff --git a/sql/procedures.sql b/sql/procedures.sql index de74458..eae01bd 100644 --- a/sql/procedures.sql +++ b/sql/procedures.sql @@ -290,7 +290,7 @@ declare inv_id uuid; stake_id uuid; stake_created_at timestamp; - stake_amount integer; + total_stake_amount integer; begin select completion_time_in_mins into item_stake_duration @@ -299,12 +299,12 @@ begin where inventory_item.id = p_inventory_item_id; select - inventory_item.id as inv_id, - staking_event.id as stake_id, - staking_event.created_at as stake_created_at + inventory_item.id, + staking_event.id, + staking_event.created_at from inventory_item left join staking_event - on staking_event.inventory_item_id = inv_id + on staking_event.inventory_item_id = inventory_item.id where inventory_item.id = p_inventory_item_id and inventory_item.user_id = p_user_id order by stake_created_at desc limit 1 into inv_id, stake_id, stake_created_at; @@ -321,16 +321,16 @@ begin using message = 'Unable to find an inventory item that is owned and not actively staked'; end if; - select claim_amount + claim_boost - into stake_amount + select claim_amount + into total_stake_amount from inventory_item join store_item on inventory_item.store_item_id = store_item.id - join upgrade_item on store_item.id = upgrade_item.store_item_id + left join upgrade_item on store_item.id = upgrade_item.store_item_id and upgrade_item.tier = inventory_item.tier where inventory_item.id = p_inventory_item_id; insert into staking_event(user_id, well_id, inventory_item_id, duration_in_mins, stake_amount) - values (p_user_id, p_well_id, p_inventory_item_id, item_stake_duration, stake_amount) + values (p_user_id, p_well_id, p_inventory_item_id, item_stake_duration, total_stake_amount) returning id into staking_event_id; return staking_event_id; diff --git a/test-endpoints.restclient b/test-endpoints.restclient index 5a1b745..d9446ab 100644 --- a/test-endpoints.restclient +++ b/test-endpoints.restclient @@ -40,7 +40,7 @@ PUT http://localhost:3000/api/user/:user_id/account POST http://localhost:3000/api/user/:user_id/clear-data :headers -# Get bank account +# Get leaderboards GET http://localhost:3000/api/leaderboards :headers @@ -64,7 +64,7 @@ POST http://localhost:3000/api/user/:user_id/inventory-items/ # Upgrade an owned item PUT http://localhost:3000/api/user/:user_id/inventory-items/ :headers -{ "inventoryItemId": "26e4b397-2b01-4c73-a14e-4ea4ae3ec1a5" } +{ "inventoryItemId": "2bd5f846-ce1d-45be-998e-26d2e97b7f68" } # Get stakes GET http://localhost:3000/api/user/:user_id/stakes/ @@ -73,8 +73,8 @@ GET http://localhost:3000/api/user/:user_id/stakes/ # Start a stake POST http://localhost:3000/api/user/:user_id/stakes/start :headers -{ "inventoryItemId": "26e4b397-2b01-4c73-a14e-4ea4ae3ec1a5" - , "wellId": "ea4ad43c-d153-4fd4-819d-3c0339102d1e" } +{ "inventoryItemId": "2bd5f846-ce1d-45be-998e-26d2e97b7f68" + , "wellId": "588ad177-83ca-4a5f-9672-bf97783ea42f" } # Claim a stake POST http://localhost:3000/api/user/:user_id/stakes/claim