quillsql 1.7__tar.gz → 1.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {quillsql-1.7 → quillsql-1.9}/PKG-INFO +1 -1
- {quillsql-1.7 → quillsql-1.9}/quillsql/core.py +19 -23
- {quillsql-1.7 → quillsql-1.9}/quillsql.egg-info/PKG-INFO +1 -1
- {quillsql-1.7 → quillsql-1.9}/setup.py +1 -1
- {quillsql-1.7 → quillsql-1.9}/tests/simple_test.py +0 -20
- {quillsql-1.7 → quillsql-1.9}/LICENSE +0 -0
- {quillsql-1.7 → quillsql-1.9}/README.md +0 -0
- {quillsql-1.7 → quillsql-1.9}/quillsql/__init__.py +0 -0
- {quillsql-1.7 → quillsql-1.9}/quillsql.egg-info/SOURCES.txt +0 -0
- {quillsql-1.7 → quillsql-1.9}/quillsql.egg-info/dependency_links.txt +0 -0
- {quillsql-1.7 → quillsql-1.9}/quillsql.egg-info/requires.txt +0 -0
- {quillsql-1.7 → quillsql-1.9}/quillsql.egg-info/top_level.txt +0 -0
- {quillsql-1.7 → quillsql-1.9}/setup.cfg +0 -0
- {quillsql-1.7 → quillsql-1.9}/tests/__init__.py +0 -0
- {quillsql-1.7 → quillsql-1.9}/tests/cache_test.py +0 -0
- {quillsql-1.7 → quillsql-1.9}/tests/external_test.py +0 -0
|
@@ -7,8 +7,8 @@ import redis
|
|
|
7
7
|
from psycopg2.extensions import make_dsn
|
|
8
8
|
|
|
9
9
|
## The host url of the Quill metadata server
|
|
10
|
-
|
|
11
|
-
HOST = "http://localhost:8080"
|
|
10
|
+
HOST = "https://quill-344421.uc.r.appspot.com" # or "http://localhost:8080"
|
|
11
|
+
# HOST = "http://localhost:8080"
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
## The TTL for new cache entries (default: 1h)
|
|
@@ -43,7 +43,8 @@ class CachedPool:
|
|
|
43
43
|
|
|
44
44
|
def exec(self, sql):
|
|
45
45
|
self.cur.execute(sql)
|
|
46
|
-
|
|
46
|
+
rows = self.cur.fetchall()
|
|
47
|
+
return [json.loads(json.dumps(row, default=str)) for row in rows]
|
|
47
48
|
|
|
48
49
|
def query(self, sql):
|
|
49
50
|
if not self.cache:
|
|
@@ -89,7 +90,7 @@ def handleQueryTask(org_id, metadata, private_key, target_pool):
|
|
|
89
90
|
|
|
90
91
|
formatted_result = {
|
|
91
92
|
"fields": fields,
|
|
92
|
-
"rows": [dict(
|
|
93
|
+
"rows": [dict(row) for row in query_result],
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
for row in formatted_result["rows"]:
|
|
@@ -128,6 +129,8 @@ def handleConfigTask(org_id, metadata, private_key, target_pool):
|
|
|
128
129
|
if not dash_config:
|
|
129
130
|
dash_config["filters"] = []
|
|
130
131
|
|
|
132
|
+
# TODO: MOVE TO DATABASE LEVEL
|
|
133
|
+
# dash_config["dateFilter"]["comparison"] = True
|
|
131
134
|
return dash_config
|
|
132
135
|
|
|
133
136
|
|
|
@@ -187,14 +190,7 @@ def handleItemTask(org_id, metadata, private_key, target_pool):
|
|
|
187
190
|
cursor = target_pool.cursor()
|
|
188
191
|
|
|
189
192
|
query_result = target_pool.query(response_data["query"])
|
|
190
|
-
|
|
191
|
-
if "compareQuery" in response_data:
|
|
192
|
-
compare_rows_result = target_pool.query(response_data["compareQuery"])
|
|
193
|
-
columns = [desc[0] for desc in cursor.description]
|
|
194
|
-
|
|
195
|
-
if compare_rows_result:
|
|
196
|
-
compare_rows = [dict(zip(columns, row)) for row in compare_rows_result]
|
|
197
|
-
rows = [dict(json.loads(json.dumps(row, default=str))) for row in query_result]
|
|
193
|
+
rows = [dict(row) for row in query_result]
|
|
198
194
|
fields = [
|
|
199
195
|
{"name": desc[0], "dataTypeID": desc[1]}
|
|
200
196
|
for desc in cursor.description
|
|
@@ -205,21 +201,21 @@ def handleItemTask(org_id, metadata, private_key, target_pool):
|
|
|
205
201
|
if field_to_remove in row:
|
|
206
202
|
del row[field_to_remove]
|
|
207
203
|
|
|
208
|
-
|
|
204
|
+
compare_rows = None
|
|
205
|
+
if "compareQuery" in response_data:
|
|
206
|
+
compare_rows_result = target_pool.query(response_data["compareQuery"])
|
|
207
|
+
compare_rows = [dict(row) for row in compare_rows_result]
|
|
209
208
|
for row in compare_rows:
|
|
210
209
|
row = {key: value for key, value in row.items() if key != field_to_remove}
|
|
211
210
|
if field_to_remove in row:
|
|
212
211
|
del row[field_to_remove]
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
else:
|
|
222
|
-
return {**resp_data, "fields": fields, "rows": rows}
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
**resp_data,
|
|
215
|
+
"fields": fields,
|
|
216
|
+
"rows": rows,
|
|
217
|
+
**({ "comparisonRows": compare_rows } if compare_rows else {})
|
|
218
|
+
}
|
|
223
219
|
|
|
224
220
|
|
|
225
221
|
## handles org tasks
|
|
@@ -61,25 +61,6 @@ def test_config_gets_admin_metadata():
|
|
|
61
61
|
assert "customer_id" not in row
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
# def test_config_gets_admin_metadata_2():
|
|
65
|
-
# res = quill.query(
|
|
66
|
-
# org_id="2",
|
|
67
|
-
# data={
|
|
68
|
-
# "metadata": {
|
|
69
|
-
# "id": "65895d225cd2e8cb2bd8542d",
|
|
70
|
-
# "orgId": "2",
|
|
71
|
-
# "clientId": "6579031b3e41c378aa8180ec",
|
|
72
|
-
# "task": "item",
|
|
73
|
-
# "filters": [],
|
|
74
|
-
# }
|
|
75
|
-
# },
|
|
76
|
-
# )
|
|
77
|
-
|
|
78
|
-
# print(res)
|
|
79
|
-
# assert res is not None
|
|
80
|
-
# assert "rows" in res
|
|
81
|
-
|
|
82
|
-
|
|
83
64
|
def test_handles_empty_client_id():
|
|
84
65
|
res = quill.query(
|
|
85
66
|
org_id="2",
|
|
@@ -285,7 +266,6 @@ def test_view_works_correctly_with_clientId():
|
|
|
285
266
|
},
|
|
286
267
|
)
|
|
287
268
|
|
|
288
|
-
print(res)
|
|
289
269
|
assert res is not None
|
|
290
270
|
assert "errorMessage" not in res
|
|
291
271
|
assert "code" in res
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|