static string API_KEY = ""; // Needed! #endregion Fields #region Methods public static void SyncUserVoiceSiteToRavenDb(Site site, string ravenDbServer, string database) { Console.WriteLine("SyncUserVoiceSite started for UserVoiceSite {0} to RavenDbServer {1}", site.Name, ravenDbServer + "@" + database); Stopwatch watch = new Stopwatch(); watch.Start(); var client = new UserVoice.Client(site.Subdomain, "", apiSecret: ""); // for closed stuff we need the filter=closed (which is the only filter i can access ?? - otherwise just suggestions.json as endpoint var suggestions = client.GetCollection("/api/v1/forums/" + site.Id + "/suggestions.json?filter=closed"); var totalNumber = suggestions.Count; Console.WriteLine("Total suggestions: " + totalNumber); using (var documentStore = new DocumentStore { Url = ravenDbServer, DefaultDatabase = database}) { documentStore.Initialize(); using (var bulkInsert = documentStore.BulkInsert(options: new BulkInsertOptions() { CheckForUpdates = true, BatchSize = 100 })) { int i = 0; foreach (var suggestionJson in suggestions) { int percentage = 0; if(i > 0) { percentage = i * 100/totalNumber; } Console.WriteLine("Completed {0}% (Counter: {1})", percentage, i); var suggestionObject = suggestionJson.ToObject<Suggestion>(); suggestionObject.Site = site; bulkInsert.Store(suggestionObject); i++; } } } watch.Stop(); Console.WriteLine("Job for UserVoiceSite {0} finished. Elpased Time: {1}:{2}", site.Name, watch.Elapsed.Minutes, watch.Elapsed.Seconds); }
public void ShouldGetPublicForumData() { UserVoice.Client publicClient = getUnsignedClient(); AssertEqual(false, (bool)publicClient.GetCollection("/api/v1/forums", 1)[0]["private"]); }