Browse Source

minor cleanup, fix logic to check for double processing

master
Wesley Kerfoot 4 years ago
parent
commit
7bdde692ab
  1. 14
      src/twit2blogpkg/server.nim

14
src/twit2blogpkg/server.nim

@ -49,17 +49,17 @@ proc insertThread(thread : TwitterThread) =
thread.author, thread.author,
thread.tweets) thread.tweets)
get "/thread/:author/status/:threadID": get "/thread/:author/status/:tweetID":
let threadID = data{"threadID"}.getStr() let tweetID = data{"tweetID"}.getStr()
let author = data{"author"}.getStr() let author = data{"author"}.getStr()
let thread = threadExists(threadID, author) let thread = threadExists(tweetID, author)
if thread.isSome: if thread.isSome:
respond thread.get.tweets respond thread.get.tweets
else: else:
chan.send( chan.send(
ThreadRequest(tweetID: data{"threadID"}.getStr(), ThreadRequest(tweetID: data{"tweetID"}.getStr(),
author: data{"author"}.getStr()) author: data{"author"}.getStr())
) )
respond "Hang on, we're grabbing your thread :) Come back to this page later." respond "Hang on, we're grabbing your thread :) Come back to this page later."
@ -75,11 +75,10 @@ proc handleRenders* =
while true: while true:
let t : ThreadRequest = chan.recv() let t : ThreadRequest = chan.recv()
if processing.contains(t.author & t.tweetID): if processing.contains(t.author & t.tweetID) or threadExists(t.tweetID, t.author).isSome:
echo "It contained the item, so we're skipping it"
continue continue
processing.incl(t.author & t.tweetID)
let tweets = t.tweetID.renderThread(t.author) let tweets = t.tweetID.renderThread(t.author)
if tweets.isSome: if tweets.isSome:
@ -88,3 +87,4 @@ proc handleRenders* =
author: t.author, author: t.author,
tweets: tweets.get.join("\n")) tweets: tweets.get.join("\n"))
) )
processing.excl(t.author & t.tweetID)

Loading…
Cancel
Save