Compare commits

...

12 Commits

Author SHA1 Message Date
Mario de Frutos
ef7c5d9218 Merge pull request #398 from CartoDB/development
Release python library version 0.15.4
2017-08-30 17:46:25 +02:00
Mario de Frutos
bd63346c50 Updated NEWS.md 2017-08-30 17:44:33 +02:00
Mario de Frutos
c878384955 Merge pull request #397 from CartoDB/fix_invalid_mapzen_isochrones
Fix invalid geometries due to generalize option
2017-08-30 17:42:50 +02:00
Mario de Frutos
475df918c7 Fix invalid geometries due to generalize option
They add a note saying that use their simplification option could
lead to a self-intersection (which is the problem we have) and it's
creating invalid geometries

See it here https://mapzen.com/documentation/mobility/isochrone/api-reference/#other-request-parameters
2017-08-30 17:35:08 +02:00
Mario de Frutos
937440c79a Update NEWS.md 2017-08-24 16:09:10 +02:00
Mario de Frutos
cb39640179 Merge pull request #396 from CartoDB/development
Release 0.15.3 for the python library
2017-08-24 16:06:34 +02:00
Mario de Frutos
727e5c09a9 Merge pull request #395 from CartoDB/remove_quota_do
Remove quota DO
2017-08-24 16:04:40 +02:00
Mario de Frutos
c13dba71a4 Deactivated DO credits usage for users that have quota
See https://github.com/CartoDB/bigmetadata/issues/215
2017-08-24 14:35:20 +02:00
Javier Torres
55cd62f6dc Merge pull request #394 from CartoDB/UpdatedUserDatabaseConfiguration
Updated configuration
2017-08-24 11:55:33 +02:00
Antonio
00424a0314 Added suggested changes 2017-08-24 10:05:23 +02:00
Antonio
e30b081cbc Added suggestions from CR 2017-08-16 11:11:33 +02:00
Antonio
797a2dbd24 Updated the User database configuration section 2017-08-11 10:21:10 +02:00
6 changed files with 34 additions and 11 deletions

11
NEWS.md
View File

@@ -1,3 +1,14 @@
August 30th, 2017
=============
* Version `0.15.4` of the python library
* Fixed invalid geometries for isochrones due to `generalize` option. See #397
August 24th, 2017
=============
* Improved the documentation
* Version `0.15.3` of the python library
* Disabled DO quota check for users that have it configured . See #395
August 23th, 2017
=============
* Version `0.27.0` of the server

View File

@@ -92,7 +92,7 @@ Steps to deploy a new Data Services API version :
```
- Give permission to execute and select to the `dataservices_user` user:
```
psql -U postgres -d dataservices_db -c "BEGIN;CREATE EXTENSION IF NOT EXISTS observatory; COMMIT" -e
psql -U postgres -d dataservices_db -c "BEGIN;CREATE EXTENSION IF NOT EXISTS observatory VERSION 'dev'; COMMIT" -e
psql -U postgres -d dataservices_db -c "BEGIN;GRANT SELECT ON ALL TABLES IN SCHEMA cdb_observatory TO dataservices_user; COMMIT" -e
psql -U postgres -d dataservices_db -c "BEGIN;GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_observatory TO dataservices_user; COMMIT" -e
psql -U postgres -d dataservices_db -c "BEGIN;GRANT SELECT ON ALL TABLES IN SCHEMA observatory TO dataservices_user; COMMIT" -e
@@ -254,14 +254,16 @@ jsonb_set(
```
### User database configuration
#### Option 1 (manually)
User (client) databases need also some configuration so that the client extension can access the server:
#### Users/Organizations
##### Users/Organizations
```sql
SELECT CDB_Conf_SetConf('user_config', '{"is_organization": false, "entity_name": "<YOUR_USERNAME>"}');
```
#### Dataservices server
##### Dataservices server
The `geocoder_server_config` (the name is not accurate for historical reasons) entry points
to the dataservices server DB (you can use a specific database for the server or your same user's):
@@ -272,10 +274,14 @@ SELECT CDB_Conf_SetConf(
'{ "connection_str": "host=localhost port=5432 dbname=<SERVER_DB_NAME> user=postgres"}'
);
```
#### Search path
##### Search path
The search path must be configured in order to be able to execute the functions without using the schema:
```sql
ALTER ROLE "<USER_ROLE>" SET search_path="$user", public, cartodb, cdb_dataservices_client;
```
#### Option 2 (from builder)
See [the **Configuring Dataservices** documentation](http://cartodb.readthedocs.io/en/latest/operations/configure_data_services.html)

View File

@@ -28,7 +28,7 @@ def coordinates_to_polygon(coordinates):
wkt_coordinates = ','.join(result_coordinates)
try:
sql = "SELECT ST_MakePolygon(ST_GeomFromText('LINESTRING({0})', 4326)) as geom".format(wkt_coordinates)
sql = "SELECT ST_CollectionExtract(ST_MakeValid(ST_MakePolygon(ST_GeomFromText('LINESTRING({0})', 4326))),3) as geom".format(wkt_coordinates)
geometry = plpy.execute(sql, 1)[0]['geom']
except BaseException as e:
plpy.warning("Can't generate POLYGON from coordinates: {0}".format(e))

View File

@@ -134,7 +134,10 @@ class QuotaChecker:
service_type = self._user_service_config.service_type
current_used = self._user_service.used_quota(service_type, today)
if soft_limit or (user_quota > 0 and current_used < user_quota):
# Quick workaround so we don't take into account numer of credits
# spent for users that have defined the quota.
# See https://github.com/CartoDB/bigmetadata/issues/215
if soft_limit or (user_quota > 0):
return True
else:
return False

View File

@@ -10,7 +10,7 @@ from setuptools import setup, find_packages
setup(
name='cartodb_services',
version='0.15.2',
version='0.15.4',
description='CartoDB Services API Python Library',

View File

@@ -126,12 +126,15 @@ class TestQuotaService(TestCase):
qs.increment_isolines_service_use(amount=1500000)
assert qs.check_user_quota() is False
# Quick workaround so we don't take into account numer of credits
# spent for users that have defined the quota.
# See https://github.com/CartoDB/bigmetadata/issues/215
def test_should_check_user_obs_snapshot_quota_correctly(self):
qs = self.__build_obs_snapshot_quota_service('test_user')
qs.increment_success_service_use()
assert qs.check_user_quota() is True
qs.increment_success_service_use(amount=100000)
assert qs.check_user_quota() is False
assert qs.check_user_quota() is True
def test_should_check_org_obs_snapshot_quota_correctly(self):
qs = self.__build_obs_snapshot_quota_service('test_user',
@@ -139,14 +142,14 @@ class TestQuotaService(TestCase):
qs.increment_success_service_use()
assert qs.check_user_quota() is True
qs.increment_success_service_use(amount=100000)
assert qs.check_user_quota() is False
assert qs.check_user_quota() is True
def test_should_check_user_obs_quota_correctly(self):
qs = self.__build_obs_snapshot_quota_service('test_user')
qs.increment_success_service_use()
assert qs.check_user_quota() is True
qs.increment_success_service_use(amount=100000)
assert qs.check_user_quota() is False
assert qs.check_user_quota() is True
def test_should_check_org_obs_quota_correctly(self):
qs = self.__build_obs_quota_service('test_user',
@@ -154,7 +157,7 @@ class TestQuotaService(TestCase):
qs.increment_success_service_use()
assert qs.check_user_quota() is True
qs.increment_success_service_use(amount=100000)
assert qs.check_user_quota() is False
assert qs.check_user_quota() is True
def __prepare_quota_service(self, username, service, quota, provider,
orgname, soft_limit, end_date):