Commit b39e8791 authored by Christine Plumejeaud's avatar Christine Plumejeaud
Browse files

Fixed a problem on fieldnames request

ports api is filled
parent 0c5630a5
...@@ -138,14 +138,14 @@ def readFieldnames(api, schema='navigoviz') : ...@@ -138,14 +138,14 @@ def readFieldnames(api, schema='navigoviz') :
schema = 'ports' schema = 'ports'
#API;name;shortname;type;description #API;name;shortname;type;description
query = """SELECT case when c.table_name= 'built_travels' then 'travels' else 'pointcalls' end as API, query = """SELECT %s as API,
c.column_name as name, c.column_name as name,
case when c.table_name= 'built_travels' then 't' else 'p' end||navigo.pystrip(to_char(c.ordinal_position::int, '009')) as shortname, case when c.table_name= 'built_travels' then 't' else (case when c.table_name= 'port_points' then 'pp' else 'p' end) end||navigo.pystrip(to_char(c.ordinal_position::int, '009')) as shortname,
c.data_type as type, pgd.description as description c.data_type as type, pgd.description as description
FROM information_schema.columns c FROM information_schema.columns c
left outer join pg_catalog.pg_description pgd on (pgd.objsubid=c.ordinal_position ) left outer join pg_catalog.pg_description pgd on (pgd.objsubid=c.ordinal_position )
left outer join pg_catalog.pg_statio_all_tables st on (pgd.objoid=st.relid and c.table_schema=st.schemaname and c.table_name=st.relname) left outer join pg_catalog.pg_statio_all_tables st on (pgd.objoid=st.relid and c.table_schema=st.schemaname and c.table_name=st.relname)
where c.table_name in ('%s') and c.table_schema = '%s' and pgd.objoid = st.relid;"""% (table_name, schema) where c.table_name in ('%s') and c.table_schema = '%s' and pgd.objoid = st.relid;"""% (api, table_name, schema)
#print(query) #print(query)
metadata = retrieveDataFromPostgres(query) metadata = retrieveDataFromPostgres(query)
...@@ -171,6 +171,8 @@ def getFieldnames(): ...@@ -171,6 +171,8 @@ def getFieldnames():
http://127.0.0.1/api/fieldnames/?format=json&shortenfields=true&api=pointcalls http://127.0.0.1/api/fieldnames/?format=json&shortenfields=true&api=pointcalls
http://127.0.0.1/api/fieldnames/?format=csv&shortenfields=true&api=pointcalls http://127.0.0.1/api/fieldnames/?format=csv&shortenfields=true&api=pointcalls
http://data.portic.fr/api/fieldnames/?format=json
""" """
# Filter to keep desired API # Filter to keep desired API
...@@ -581,7 +583,7 @@ def getFlows(): ...@@ -581,7 +583,7 @@ def getFlows():
from navigoviz.built_travels from navigoviz.built_travels
where """+filter_clauseINOUT+""" where """+filter_clauseINOUT+"""
and distance_dep_dest = 0 and distance_dep_dest = 0
and (departure_action like 'Sailing around' or departure_action like 'In-out' ) and (departure_action like 'Sailing around' or departure_action like 'In-out' or departure_action like 'Transit')
) as k ) as k
where ship_id = k.subject and """+filter_clause+""" where ship_id = k.subject and """+filter_clause+"""
and """+filter_degree_in+""" and """+filter_degree_out+""" and """+filter_degree_in+""" and """+filter_degree_out+"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment