Resources information on planet list

* Added resource information records to the planet list's response.

* Added a database view and the corresponding row mapper and DAO method
which can be used as the data source for the planet list's resource
information. For now this view always returns 0 for both civilian and
military investments.

* Added new tab to display resource information on the planet list page.
The old version of the economy tab will be kept until the corresponding
data no longer exists.

* The following SQL scripts must be re-executed to upgrade a database:
  -> 040-functions/167-planet-list.sql
This commit is contained in:
Emmanuel BENOîT 2012-02-15 14:45:43 +01:00
parent bf6bea5a79
commit 96670d45be
15 changed files with 1079 additions and 31 deletions
legacyworlds-server-data/db-structure/parts/040-functions

View file

@ -3,7 +3,7 @@
--
-- Views for empires' planet lists
--
-- Copyright(C) 2004-2010, DeepClone Development
-- Copyright(C) 2004-2012, DeepClone Development
-- --------------------------------------------------------
@ -114,6 +114,58 @@ CREATE VIEW emp.planets_list_fleets
END );
/*
* Planet list resources information
* ----------------------------------
*
* This view is used to display the resources-related information in the
* planet list pages. All rows in the view are ordered using the usual
* resource ordering view.
*
* FIXME: time-related constants are hardcoded.
* FIXME: civilian and military investments are set to 0.
*
* Columns:
* empire_id The empire's identifier
* planet_id The planet's identifier
* pres_income The income for this type of resources on a period
* of 12h RT / one month GT.
* pres_upkeep The upkeep for this type of resources on a period
* of 12h RT / one month GT.
* civ_investment The current amount invested in the civillian build
* queue (FIXME: forced to 0)
* mil_investment The current amount invested in the military build
* queue (FIXME: forced to 0)
*/
DROP VIEW IF EXISTS emp.plist_resources_view;
CREATE VIEW emp.plist_resources_view
AS SELECT _emp_planet.empire_id , _emp_planet.planet_id ,
_name.translated_string AS resource_name ,
FLOOR( _pres.pres_income * 720.0 )::BIGINT AS pres_income ,
CEIL( _pres.pres_upkeep * 720.0 )::BIGINT AS pres_upkeep ,
0::BIGINT AS civ_investment ,
0::BIGINT AS mil_investment
FROM emp.planets _emp_planet
INNER JOIN verse.planet_resources _pres
USING ( planet_id )
INNER JOIN naming.empire_names _emp_name
ON _emp_name.id = _emp_planet.empire_id
INNER JOIN users.credentials _creds
ON _creds.address_id = _emp_name.owner_id
INNER JOIN defs.translations _name
ON _name.string_id = resource_name_id
AND _name.lang_id = _creds.language_id
INNER JOIN defs.ordered_resources_view _res_def
USING ( resource_name_id )
WHERE _pres.pres_income > 0
OR _pres.pres_upkeep > 0
ORDER BY _res_def.resource_ordering;
GRANT SELECT
ON emp.plist_resources_view
TO :dbuser;
--
-- Actual planet list
--