Skip to content

Instantly share code, notes, and snippets.

@sanealytics
Created September 9, 2016 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanealytics/6152318c478b049b9faa04294be4820b to your computer and use it in GitHub Desktop.
Save sanealytics/6152318c478b049b9faa04294be4820b to your computer and use it in GitHub Desktop.
library(mongolite)
# Connections to mongo
instagram <- mongo(collection = "InstagramV4", db = "DeepDress", url = "mongodb://localhost", verbose = FALSE)
matches <- mongo(collection = "MatchesV4", db = "DeepDress", url = "mongodb://localhost", verbose = FALSE)
corrections <- mongo(collection = "CorrectionsV4", db = "DeepDress", url = "mongodb://localhost", verbose = FALSE)
# Get Instagram data we saved earlier
ids.df <- instagram$find(fields = '{"_id" : 1, "payload.created_time" : 1}')
ids.df.simple <- data.frame(id = ids.df$`_id`,
created_time = ids.df$payload$created_time,
stringsAsFactors = FALSE)
# Reorder by newest
ids.df.simple <- ids.df.simple[order(-as.numeric(ids.df.simple$created_time)), ]
# What has already been corrected by users
ids.done <- corrections$find(fields = '{"id" : 1}') # What has already been corrected
# What's left
ids.df.todo <- setdiff(ids.df.simple$id, ids.done$id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment