This repository has been archived on 2025-01-04. You can view files and clone it, but cannot push or open issues or pull requests.
lwb6/legacyworlds-server-data/db-structure/tests/admin/040-functions/145-resource-providers/050-scaled-mining-weights-view.sql
Emmanuel BENOîT bf6bea5a79 Extracted quantities update as soon as possible
* The quantities of resources extracted from mines will now be updated
as soon as they have a reason to. This includes planet assignment,
abandonment, ownership changes, and updates to mining priorities.

* The mining update will now remove the current resource income from the
providers, and only then re-compute all extracted quantities. This is
more logical and corresponds to the way the other game updates work.

* Fixed bug in extraction computation where the size of the planet's
happy population was used instead of the happy/total ratio when
adjusting the mining production for riots.

* The following SQL scripts must be re-executed to upgrade a database:
  -> 040-functions/040-empire.sql
  -> 040-functions/145-resource-providers.sql
  -> 040-functions/147-empire-mining.sql
  -> 050-updates/120-planet-mining.sql
2012-02-09 10:54:00 +01:00

44 lines
No EOL
1.3 KiB
PL/PgSQL

/*
* Test emp.scaled_mining_weights_view
*/
BEGIN;
/* Create a table which will server as an alternate source for
* emp.mining_settings_view ; the table is not temporary (PostgreSQL
* won't allow replacing the view otherwise), but will be dropped
* on rollback anyway.
*/
CREATE TABLE fake_mining_settings(
planet_id INT ,
resource_name_id INT ,
mset_weight INT ,
mset_specific BOOLEAN
);
CREATE OR REPLACE VIEW emp.mining_settings_view
AS SELECT * FROM fake_mining_settings;
/* Insert fake records for each possible mining setting */
INSERT INTO fake_mining_settings VALUES
( 1 , 0 , 0 , FALSE ) ,
( 1 , 1 , 1 , FALSE ) ,
( 1 , 2 , 2 , FALSE ) ,
( 1 , 3 , 3 , FALSE ) ,
( 1 , 4 , 4 , FALSE );
/***** TESTS BEGIN HERE *****/
SELECT plan( 2 );
SELECT diag_test_name( 'emp.scaled_mining_weights_view - Rows present' );
SELECT isnt( COUNT(*)::INT , 0 )
FROM emp.scaled_mining_weights_view;
SELECT diag_test_name( 'emp.scaled_mining_weights_view - weight = game.resources.weightBase ^ setting' );
SELECT sys.uoc_constant( 'game.resources.weightBase' , '(test)' , 'Resources' , 10.0 );
SELECT is_empty( $$
SELECT * FROM emp.scaled_mining_weights_view
WHERE pmc_weight IS NULL
OR pmc_weight <> POW( 10 , resource_name_id )
$$ );
SELECT * FROM finish( );
ROLLBACK;