From 7bdde692ab333a268b87beecd1d0f579575a611f Mon Sep 17 00:00:00 2001 From: Wesley Kerfoot Date: Sat, 1 Feb 2020 00:35:26 -0500 Subject: [PATCH] minor cleanup, fix logic to check for double processing --- src/twit2blogpkg/server.nim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/twit2blogpkg/server.nim b/src/twit2blogpkg/server.nim index 378c9d6..01ae0d9 100644 --- a/src/twit2blogpkg/server.nim +++ b/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)