refactor: 💡 remove table sources filter support

BREAKING CHANGE: remove table sources `filter` query param support
This commit is contained in:
Stepan Kuzmin 2019-03-16 19:02:56 +03:00
parent 5eeef48b30
commit a7c17934e2
5 changed files with 3 additions and 22 deletions

11
Cargo.lock generated
View File

@ -732,15 +732,6 @@ dependencies = [
"linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mapbox_expressions_to_sql"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "martin"
version = "0.2.0"
@ -751,7 +742,6 @@ dependencies = [
"env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mapbox_expressions_to_sql 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"postgres 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
"r2d2 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2049,7 +2039,6 @@ dependencies = [
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4d06ff7ff06f729ce5f4e227876cb88d10bc59cd4ae1e09fbb2bde15c850dc21"
"checksum mapbox_expressions_to_sql 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e758ea2ad79fc2699d1ea9b3ce985bea7ba72ea8090925a79cb64d44eaf6236"
"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
"checksum md5 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "79c56d6a0b07f9e19282511c83fc5b086364cbae4ba8c7d5f190c3d9b0425a48"
"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a"

View File

@ -10,7 +10,6 @@ docopt = "1"
env_logger = "0.6"
futures = "0.1"
log = "0.4"
mapbox_expressions_to_sql = "0.1.0"
num_cpus = "1.0"
postgres = { version = "0.15", features = ["with-time", "with-uuid", "with-serde_json"] }
r2d2 = "0.8"

View File

@ -3,7 +3,6 @@ extern crate actix_web;
extern crate docopt;
extern crate env_logger;
extern crate futures;
extern crate mapbox_expressions_to_sql;
extern crate tilejson;
#[macro_use]
extern crate log;

View File

@ -3,5 +3,5 @@ SELECT ST_AsMVT(tile, '{id}', {extent}, 'geom' {id_column}) FROM (
SELECT
ST_AsMVTGeom({geometry_column_mercator}, bounds.mercator, {extent}, {buffer}, {clip_geom}) AS geom {properties}
FROM {id}, bounds
WHERE {geometry_column} && bounds.original {condition}
WHERE {geometry_column} && bounds.original
) AS tile WHERE geom IS NOT NULL

View File

@ -1,4 +1,3 @@
use mapbox_expressions_to_sql;
use std::collections::HashMap;
use std::error::Error;
use std::io;
@ -34,7 +33,7 @@ impl Source for TableSource {
&self,
conn: &PostgresConnection,
xyz: &XYZ,
query: &Query,
_query: &Query,
) -> Result<Tile, io::Error> {
let mercator_bounds = utils::tilebbox(xyz);
@ -65,10 +64,6 @@ impl Source for TableSource {
.clone()
.map_or("".to_string(), |id_column| format!(", '{}'", id_column));
let condition = query
.get("filter")
.and_then(|filter| mapbox_expressions_to_sql::parse(filter).ok());
let query = format!(
include_str!("scripts/get_tile.sql"),
id = self.id,
@ -80,8 +75,7 @@ impl Source for TableSource {
extent = self.extent.unwrap_or(DEFAULT_EXTENT),
buffer = self.buffer.unwrap_or(DEFAULT_BUFFER),
clip_geom = self.clip_geom.unwrap_or(DEFAULT_CLIP_GEOM),
properties = properties,
condition = condition.map_or("".to_string(), |condition| format!("AND {}", condition)),
properties = properties
);
let tile: Tile = conn