Merge pull request #124 from CartoDB/release-v-1.0.0

Release v 1.0.0
This commit is contained in:
Rafa de la Torre 2016-06-28 17:19:32 +02:00 committed by GitHub
commit 0dad5427c4
11 changed files with 10190 additions and 8818 deletions

26
NEWS.md
View File

@ -1,3 +1,29 @@
1.0.0 (6/27/2016)
-----
* Incremented to 1.0.0 to be in compliance with [SemVer](http://semver.org/),
which disallows use of 0.x.x versions. This also reflects that we are
already in production.
__API Changes__
* Added `OBS_DumpVersion` to look up version data ([#118](https://github.com/CartoDB/observatory-extension/pull/118))
__Improvements__
* Whether data exists for a geom now determined by polygon intersection instead of
BBOX overlap ([#119](https://github.com/CartoDB/observatory-extension/pull/119))
* Automated tests cover Spanish and UK data
([#115](https://github.com/CartoDB/observatory-extension/pull/115))
* Automated tests cover `OBS_GetUSCensusMeasure`
([#105](https://github.com/CartoDB/observatory-extension/pull/105))
__Bugfixes__
* Geom table can have different `geomref_colname` than the data table
([#123](https://github.com/CartoDB/observatory-extension/pull/123))
0.0.5 (5/27/2016)
-----
* Adds new function `OBS_GetMeasureById` ([#96](https://github.com/CartoDB/observatory-extension/pull/96))

View File

@ -24,8 +24,9 @@ def query(q, is_meta=False, **options):
params['api_key'] = META_API_KEY if is_meta else API_KEY
return requests.get(url, params=params)
MEASURE_COLUMNS = [(r['id'], ) for r in query('''
SELECT id FROM obs_column
MEASURE_COLUMNS = [(r['id'], r['point_only'], ) for r in query('''
SELECT id, aggregate NOT ILIKE 'sum' as point_only
FROM obs_column
WHERE type ILIKE 'numeric'
AND weight > 0
''', is_meta=True).json()['rows']]
@ -98,14 +99,14 @@ def default_point(column_id):
return 'CDB_LatLng(40.7, -73.9)'
#def default_area(column_id):
# '''
# Returns default test area for the column_id
# '''
# point = default_point(column_id)
# area = 'ST_Transform(ST_Buffer(ST_Transform({point}, 3857), 1000), 4326)'.format(
# point=point)
# return area
def default_area(column_id):
'''
Returns default test area for the column_id
'''
point = default_point(column_id)
area = 'ST_Transform(ST_Buffer(ST_Transform({point}, 3857), 1000), 4326)'.format(
point=point)
return area
@parameterized(US_CENSUS_MEASURE_COLUMNS)
def test_get_us_census_measure_points(name):
@ -120,21 +121,23 @@ SELECT * FROM {schema}OBS_GetUSCensusMeasure({point}, '{name}')
assert_is_not_none(rows[0].values()[0])
#@parameterized(MEASURE_COLUMNS)
#def test_get_measure_areas(column_id):
# resp = query('''
#SELECT * FROM {schema}OBS_GetMeasure({area}, '{column_id}')
# '''.format(column_id=column_id,
# schema='cdb_observatory.' if USE_SCHEMA else '',
# area=default_area(column_id)))
# assert_equal(resp.status_code, 200)
# rows = resp.json()['rows']
# assert_equal(1, len(rows))
# assert_is_not_none(rows[0].values()[0])
@parameterized(MEASURE_COLUMNS)
def test_get_measure_areas(column_id, point_only):
if point_only:
return
resp = query('''
SELECT * FROM {schema}OBS_GetMeasure({area}, '{column_id}')
'''.format(column_id=column_id,
schema='cdb_observatory.' if USE_SCHEMA else '',
area=default_area(column_id)))
assert_equal(resp.status_code, 200)
rows = resp.json()['rows']
assert_equal(1, len(rows))
assert_is_not_none(rows[0].values()[0])
@parameterized(MEASURE_COLUMNS)
def test_get_measure_points(column_id):
def test_get_measure_points(column_id, point_only):
resp = query('''
SELECT * FROM {schema}OBS_GetMeasure({point}, '{column_id}')
'''.format(column_id=column_id,

View File

@ -33,7 +33,8 @@ def select_star(tablename):
cdb = Dumpr('observatory.cartodb.com','')
metadata = ['obs_table', 'obs_column_table', 'obs_column', 'obs_column_tag', 'obs_tag', 'obs_column_to_column']
metadata = ['obs_table', 'obs_column_table', 'obs_column', 'obs_column_tag',
'obs_tag', 'obs_column_to_column', 'obs_dump_version']
fixtures = [
('us.census.tiger.census_tract', 'us.census.tiger.census_tract', '2014'),

View File

@ -1,5 +1,5 @@
comment = 'CartoDB Observatory backend extension'
default_version = '0.0.5'
default_version = '1.0.0'
requires = 'postgis'
superuser = true
schema = cdb_observatory

View File

@ -199,3 +199,20 @@ BEGIN
RETURN result;
END;
$$ LANGUAGE plpgsql;
-- Function that returns the currently deployed obs_dump_version from the
-- remote table of the same name.
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_DumpVersion(
)
RETURNS TEXT
AS $$
DECLARE
result text;
BEGIN
EXECUTE '
SELECT MAX(dump_id) FROM observatory.obs_dump_version
' INTO result;
RETURN result;
END;
$$ LANGUAGE plpgsql;

View File

@ -633,7 +633,7 @@ BEGIN
q := q || q_select || format('FROM observatory.%I ', ((data_table_info)[1]->>'tablename'));
q := format(q || ' ) ' || q_sum || ' ]::numeric[] FROM _overlaps, values
WHERE values.%I = _overlaps.%I', geom_geoid_colname, geom_geoid_colname);
WHERE values.%I = _overlaps.%I', data_geoid_colname, geom_geoid_colname);
EXECUTE
q

View File

@ -114,7 +114,7 @@ BEGIN
AND
observatory.OBS_column.type = 'Geometry'
AND
$1 && bounds::box2d
ST_Intersects($1, observatory.obs_table.the_geom)
$string$ || timespan_query
USING geom;
RETURN;

View File

@ -27,3 +27,6 @@ t
_obs_standardizemeasurename_test
t
(1 row)
obs_dumpversion_notnull
t
(1 row)

View File

@ -6,6 +6,7 @@ DROP TABLE IF EXISTS observatory.obs_column;
DROP TABLE IF EXISTS observatory.obs_column_tag;
DROP TABLE IF EXISTS observatory.obs_tag;
DROP TABLE IF EXISTS observatory.obs_column_to_column;
DROP TABLE IF EXISTS observatory.obs_dump_version;
DROP TABLE IF EXISTS observatory.obs_65f29658e096ca1485bf683f65fdbc9f05ec3c5d;
DROP TABLE IF EXISTS observatory.obs_1746e37b7cd28cb131971ea4187d42d71f09c5f3;
DROP TABLE IF EXISTS observatory.obs_1a098da56badf5f32e336002b0a81708c40d29cd;

File diff suppressed because one or more lines are too long

View File

@ -75,4 +75,7 @@ SELECT cdb_observatory._OBS_GetRelatedColumn(
-- should give back a standardized measure name
SELECT cdb_observatory._OBS_StandardizeMeasureName('test 343 %% 2 qqq }}{{}}') = 'test_343_2_qqq' As _OBS_StandardizeMeasureName_test;
SELECT cdb_observatory.OBS_DumpVersion()
IS NOT NULL AS OBS_DumpVersion_notnull;
\i test/fixtures/drop_fixtures.sql