mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
Merge pull request 'Introduce limit/offset args for api list call' (#2) from dsc/suchwow:limitoffset into master
Reviewed-on: https://git.wownero.com/lza_menace/suchwow/pulls/2
This commit is contained in:
commit
93ee3355c6
1 changed files with 9 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
from flask import jsonify, Blueprint, url_for
|
from flask import jsonify, Blueprint, url_for, request, abort
|
||||||
from suchwow.models import Post
|
from suchwow.models import Post
|
||||||
from suchwow import wownero
|
from suchwow import wownero
|
||||||
|
|
||||||
|
@ -7,8 +7,15 @@ bp = Blueprint("api", "api")
|
||||||
|
|
||||||
@bp.route("/api/list")
|
@bp.route("/api/list")
|
||||||
def api_list():
|
def api_list():
|
||||||
|
limit = request.args.get('limit', 30)
|
||||||
|
offset = request.args.get('offset', 0)
|
||||||
|
if not isinstance(limit, int) or not isinstance(offset, int):
|
||||||
|
abort(500, "Bleep bleep")
|
||||||
|
if limit > 30:
|
||||||
|
limit = 30
|
||||||
|
|
||||||
all_posts = []
|
all_posts = []
|
||||||
posts = Post.select().where(Post.approved==True)
|
posts = Post.select().where(Post.approved==True).order_by(Post.timestamp.desc()).limit(limit).offset(offset)
|
||||||
for post in posts:
|
for post in posts:
|
||||||
wallet = wownero.Wallet()
|
wallet = wownero.Wallet()
|
||||||
if wallet.connected:
|
if wallet.connected:
|
||||||
|
|
Loading…
Reference in a new issue