Skip to content

Commit 2e763d1

Browse files
committed
api boundless querying, fix filters
1 parent 3470ceb commit 2e763d1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

placedump/api/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ async def get_pixel_history(
6161
This call accepts positions with X, Y coordinates in specific canvases.
6262
6363
This call accepts authors to pull pixels changed by that author.
64-
"""
6564
66-
if all(x is None for x in [x, y, canvas_id, author]):
67-
raise HTTPException(status_code=400, detail="Missing parameters.")
65+
This call accepts no arguments to pull pixels for the entire dataset.
66+
"""
6867

6968
# GOOD ENOUGH HACK
7069
if canvas_id is None:
@@ -85,28 +84,29 @@ async def get_pixel_history(
8584
# Query all with limit.
8685
filter_query = select(Pixel).order_by(Pixel.modified).limit(limit)
8786

88-
if after:
87+
if after is not None:
8988
timestamp = float(after) / 1000.0
9089
timestamp = datetime.datetime.fromtimestamp(timestamp)
90+
count_query = count_query.filter(Pixel.modified >= timestamp)
9191
filter_query = filter_query.filter(Pixel.modified >= timestamp)
9292

9393
# Canvas
94-
if canvas_id:
94+
if canvas_id is not None:
9595
count_query = count_query.filter(Pixel.board_id == canvas_id)
9696
filter_query = filter_query.filter(Pixel.board_id == canvas_id)
9797

9898
# X filters
99-
if x:
99+
if x is not None:
100100
count_query = count_query.filter(Pixel.x == x)
101101
filter_query = filter_query.filter(Pixel.x == x)
102102

103103
# Y filters
104-
if y:
104+
if y is not None:
105105
count_query = count_query.filter(Pixel.y == y)
106106
filter_query = filter_query.filter(Pixel.y == y)
107107

108108
# Filter: Author
109-
if author:
109+
if author is not None:
110110
count_query = count_query.filter(Pixel.user == author)
111111
filter_query = filter_query.filter(Pixel.user == author)
112112

0 commit comments

Comments
 (0)