New query rules, big multi-user query optimization
This commit is contained in:
parent
2127af71b4
commit
bc0ccb483a
1 changed files with 10 additions and 13 deletions
|
@ -51,25 +51,22 @@ proc genQueryParam*(query: Query): string =
|
||||||
if query.kind == users:
|
if query.kind == users:
|
||||||
return query.text
|
return query.text
|
||||||
|
|
||||||
let rewrite = rewriteReplies and query.fromUser.len > 0 and
|
|
||||||
query.kind notin {tweets, replies}
|
|
||||||
|
|
||||||
for i, user in query.fromUser:
|
for i, user in query.fromUser:
|
||||||
if rewrite:
|
param &= &"from:{user} "
|
||||||
param &= &"(from:{user}(to:{user} OR -filter:replies)) "
|
|
||||||
else:
|
|
||||||
param &= &"from:{user} "
|
|
||||||
|
|
||||||
if i < query.fromUser.high:
|
if i < query.fromUser.high:
|
||||||
param &= "OR "
|
param &= "OR "
|
||||||
|
|
||||||
|
if query.fromUser.len > 0 and query.kind in {posts, media}:
|
||||||
|
param &= "filter:self_threads OR-filter:replies "
|
||||||
|
|
||||||
if "nativeretweets" notin query.excludes:
|
if "nativeretweets" notin query.excludes:
|
||||||
param &= "include:nativeretweets "
|
param &= "include:nativeretweets "
|
||||||
|
|
||||||
|
let rewrite = query.fromUser.len > 0 and query.kind in {posts, media}
|
||||||
for f in query.filters:
|
for f in query.filters:
|
||||||
filters.add "filter:" & f
|
filters.add "filter:" & f
|
||||||
for e in query.excludes:
|
for e in query.excludes:
|
||||||
if rewrite and e == "replies": continue
|
if e == "nativeretweets": continue
|
||||||
filters.add "-filter:" & e
|
filters.add "-filter:" & e
|
||||||
for i in query.includes:
|
for i in query.includes:
|
||||||
filters.add "include:" & i
|
filters.add "include:" & i
|
||||||
|
@ -82,10 +79,10 @@ proc genQueryParam*(query: Query): string =
|
||||||
if query.near.len > 0:
|
if query.near.len > 0:
|
||||||
result &= &" near:\"{query.near}\" within:15mi"
|
result &= &" near:\"{query.near}\" within:15mi"
|
||||||
if query.text.len > 0:
|
if query.text.len > 0:
|
||||||
result &= " " & query.text
|
if result.len > 0:
|
||||||
|
result &= " " & query.text
|
||||||
if rewrite and result.len >= 500:
|
else:
|
||||||
return genQueryParam(query, rewriteReplies=false)
|
result = query.text
|
||||||
|
|
||||||
proc genQueryUrl*(query: Query): string =
|
proc genQueryUrl*(query: Query): string =
|
||||||
if query.kind notin {tweets, users}: return
|
if query.kind notin {tweets, users}: return
|
||||||
|
|
Loading…
Reference in a new issue