Commit f31ffbd442f82645bc987b1028e56c382d01ba14
1 parent
fe22425a
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
change monitor variable to created time
Showing
1 changed file
with
12 additions
and
2 deletions
Show diff stats
plugins/community_hub/facebook_stream/codfish_facebook_api.rb
| @@ -27,6 +27,7 @@ end | @@ -27,6 +27,7 @@ end | ||
| 27 | extractedComments = [] | 27 | extractedComments = [] |
| 28 | initialComments = [] | 28 | initialComments = [] |
| 29 | firstTime = true | 29 | firstTime = true |
| 30 | +read = 1 | ||
| 30 | 31 | ||
| 31 | while true | 32 | while true |
| 32 | file = open("https://graph.facebook.com/v1.0/search?q=%23#{hashtag}&type=post&access_token=#{token}") | 33 | file = open("https://graph.facebook.com/v1.0/search?q=%23#{hashtag}&type=post&access_token=#{token}") |
| @@ -41,8 +42,8 @@ while true | @@ -41,8 +42,8 @@ while true | ||
| 41 | message += i['message'] | 42 | message += i['message'] |
| 42 | end | 43 | end |
| 43 | if not_blank(message) | 44 | if not_blank(message) |
| 44 | - if mostRecent == "" or mostRecent < i["updated_time"] | ||
| 45 | - mostRecent = i["updated_time"] | 45 | + if mostRecent == "" or mostRecent < i["created_time"] |
| 46 | + mostRecent = i["created_time"] | ||
| 46 | end | 47 | end |
| 47 | 48 | ||
| 48 | extractedComments.push("#{from} said: #{message}") | 49 | extractedComments.push("#{from} said: #{message}") |
| @@ -61,6 +62,11 @@ while true | @@ -61,6 +62,11 @@ while true | ||
| 61 | # puts comment | 62 | # puts comment |
| 62 | # } | 63 | # } |
| 63 | 64 | ||
| 65 | +# extractedComments.each{|comment| | ||
| 66 | +# puts comment | ||
| 67 | +# } | ||
| 68 | + | ||
| 69 | + | ||
| 64 | newComments = extractedComments - initialComments | 70 | newComments = extractedComments - initialComments |
| 65 | newComments = newComments.uniq | 71 | newComments = newComments.uniq |
| 66 | initialComments += newComments | 72 | initialComments += newComments |
| @@ -68,7 +74,11 @@ while true | @@ -68,7 +74,11 @@ while true | ||
| 68 | newComments.each{|comment| | 74 | newComments.each{|comment| |
| 69 | puts comment | 75 | puts comment |
| 70 | } | 76 | } |
| 77 | + puts "****************************************************************************************************************" | ||
| 71 | puts "most recent post at #{mostRecent}" | 78 | puts "most recent post at #{mostRecent}" |
| 79 | + puts "Read: #{read} newComments: #{newComments.length} initialComments: #{initialComments.length} extractedComments: #{extractedComments.length} *******" | ||
| 80 | + | ||
| 81 | + read+=1 | ||
| 72 | sleep(pooling_time) | 82 | sleep(pooling_time) |
| 73 | end | 83 | end |
| 74 | 84 |