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.tweets)
get "/thread/:author/status/:threadID":
let threadID = data{"threadID"}.getStr()
get "/thread/:author/status/:tweetID":
let tweetID = data{"tweetID"}.getStr()
let author = data{"author"}.getStr()
let thread = threadExists(threadID, author)
let thread = threadExists(tweetID, author)
if thread.isSome:
respond thread.get.tweets
else:
chan.send(
ThreadRequest(tweetID: data{"threadID"}.getStr(),
ThreadRequest(tweetID: data{"tweetID"}.getStr(),
author: data{"author"}.getStr())
)
respond "Hang on, we're grabbing your thread :) Come back to this page later."
@ -75,11 +75,10 @@ proc handleRenders* =
while true:
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
processing.incl(t.author & t.tweetID)
let tweets = t.tweetID.renderThread(t.author)
if tweets.isSome:
@ -88,3 +87,4 @@ proc handleRenders* =
author: t.author,
tweets: tweets.get.join("\n"))
)
processing.excl(t.author & t.tweetID)

Loading…
Cancel
Save