public void premiumWriterClassificationTest() { DRaumStatistics drs = new DRaumStatistics(); drs.updateWritersLevel(250, 30); Assert.AreEqual(140, drs.getPremiumLevelCap()); }
internal VoteAndFlagTask(PostingManager postingManager, PublishBot publishBot, DRaumStatistics statistics, AdminBot adminBot) { this.statistics = statistics; this.adminBot = adminBot; this.publishBot = publishBot; this.posts = postingManager; this.voteAndFlagTask = this.periodicVoteAndFlagTask(new TimeSpan(0, 0, intervalVoteAndFlagCountMinutes, 0, 0), this.cancelTaskSource.Token); }
internal StatisticCollectionTask(AuthorManager authors, DRaumStatistics statistics, PostingManager posts, AdminBot adminBot) { this.authors = authors; this.posts = posts; this.statistics = statistics; this.adminBot = adminBot; this.statisticCollectionTask = this.periodicStatisticCollectionTask(new TimeSpan(0, 0, intervalStatisticCollectionMinutes, 0, 0), this.cancelTaskSource.Token); }
internal void updateTopPostStatus(DRaumStatistics statistics) { if (statistics == null) { logger.Warn("Statistik-Objekt war null und Postings werden nicht geupdatet"); return; } foreach (Posting posting in this.postings.Values) { posting.setTopPostStatus(statistics.isTopPost(posting.getUpVotes(), posting.getVoteCount())); } }
public void topPostClassificationTest() { DRaumStatistics drs = new DRaumStatistics(); drs.setVotesMedian(200); Assert.AreEqual(true, drs.isTopPost(100, 200)); Assert.AreEqual(false, drs.isTopPost(99, 200)); Assert.AreEqual(false, drs.isTopPost(100, 199)); Assert.AreEqual(false, drs.isTopPost(0, 0)); Assert.AreEqual(true, drs.isTopPost(23476238, 23476238)); drs.setVotesMedian(500); Assert.AreEqual(true, drs.isTopPost(250, 500)); Assert.AreEqual(false, drs.isTopPost(249, 499)); }
public void authorStatisticTest() { AuthorManager atm = new AuthorManager(); atm.getMedianAndTopLevel(out var median, out var top); Assert.AreEqual(0, median); Assert.AreEqual(0, top); atm.isCoolDownOver(10, "testuser1", Author.InteractionCooldownTimer.Default); atm.getMedianAndTopLevel(out median, out top); Assert.AreEqual(1, median); Assert.AreEqual(1, top); atm.isCoolDownOver(20, "testuser2", Author.InteractionCooldownTimer.Default); atm.isCoolDownOver(30, "testuser3", Author.InteractionCooldownTimer.Default); atm.isCoolDownOver(40, "testuser4", Author.InteractionCooldownTimer.Default); atm.isCoolDownOver(50, "testuser5", Author.InteractionCooldownTimer.Default); atm.getMedianAndTopLevel(out median, out top); Assert.AreEqual(1, median); Assert.AreEqual(1, top); atm.publishedSuccessfully(10); atm.publishedSuccessfully(10); atm.publishedSuccessfully(20); atm.publishedSuccessfully(20); atm.publishedSuccessfully(20); atm.publishedSuccessfully(30); atm.publishedSuccessfully(40); atm.publishedSuccessfully(40); atm.publishedSuccessfully(40); atm.publishedSuccessfully(50); atm.publishedSuccessfully(50); atm.publishedSuccessfully(50); atm.publishedSuccessfully(50); atm.publishedSuccessfully(50); atm.getMedianAndTopLevel(out median, out top); Assert.AreEqual(2, median); Assert.AreEqual(3, top); DRaumStatistics drs = new DRaumStatistics(); drs.updateWritersLevel(top, median); Assert.AreEqual(2, drs.getPremiumLevelCap()); }
private async Task checkAndUpdateAdminStatistic() { string newtext = "Interaktionen im letzten Intervall: " + this.statistics.getLastInteractionIntervalCount() + "\r\n\r\n"; newtext += "Letztes Backup: " + this.statistics.getLastBackup().ToString(Utilities.UsedCultureInfo) + "\r\n\r\n"; newtext += "Hardware-Information:\r\n" + await DRaumStatistics.getHardwareInfo() + "\r\n\r\n"; newtext += "Median-Votes: " + this.statistics.getMedianVotesPerPost() + "\r\n\r\n"; newtext += "Interaktive Nutzer: " + this.authors.getAuthorCount(); // structured logging logger.Debug("{@interactions} ; {@medianvotes} ; {@users}", this.statistics.getLastInteractionIntervalCount(), this.statistics.getMedianVotesPerPost(), this.authors.getAuthorCount()); if (!newtext.Equals(this.adminStatisticText)) { this.adminStatisticText = newtext; if (adminStatisticMessageId == -1) { Message msg = await this.adminBot.sendMessage(this.adminStatisticText); if (msg == null) { adminStatisticMessageId = -1; logger.Error("Fehler beim Senden der Statistiknachricht an den Admin"); } else { adminStatisticMessageId = msg.MessageId; } } else { await this.adminBot.editMessage(adminStatisticMessageId, this.adminStatisticText); } } }
internal InputBot(AuthorManager authors, DRaumStatistics statistics, TelegramBotClient telegramInputBot, PostingManager posts, FeedbackManager feedbackManager, Func <ITelegramBotClient, Update, CancellationToken, Task> updateHandler, Func <ITelegramBotClient, Exception, CancellationToken, Task> errorHandler) { this.authors = authors; this.statistics = statistics; this.telegramInputBot = telegramInputBot; this.posts = posts; this.feedbackManager = feedbackManager; var receiverOptions = new ReceiverOptions(); receiverOptions.AllowedUpdates = new Telegram.Bot.Types.Enums.UpdateType[] { Telegram.Bot.Types.Enums.UpdateType.CallbackQuery, Telegram.Bot.Types.Enums.UpdateType.Message }; receiverOptions.ThrowPendingUpdates = true; this.telegramInputBot.StartReceiving( updateHandler, errorHandler, receiverOptions, cancellationToken: cts.Token); }
public void topPostingFilterTest() { PostingManager pmgr = new PostingManager(); DRaumStatistics drs = new DRaumStatistics(); const int numposts = 20; for (int i = 0; i < numposts; i++) { // ein paar posts anlegen pmgr.addPosting("Bla bla bla", 10 + i * 10); } int count = 0; KeyValuePair <long, string> pair; do { pair = pmgr.getNextPostToCheck(); if (pair.Key != -1) { count++; string res = pmgr.acceptPost(pair.Key, PostingPublishManager.PublishHourType.Normal); Assert.IsTrue(res.StartsWith("Veröffentlichung")); pmgr.testPublishing(pair.Key, DateTime.Now.AddHours(-24)); for (int i = 0; i < count * 3; i++) { if (count > numposts / 2) { pmgr.downvote(pair.Key, 200 + i); } else { pmgr.upvote(pair.Key, 200 + i); } } } } while (pair.Key != -1); Assert.AreEqual(numposts, count); IEnumerable <long> list = pmgr.getDailyTopPostsFromYesterday(); bool found10 = false; bool found09 = false; bool found08 = false; foreach (long postingId in list) { if (postingId == 10) { found10 = true; } if (postingId == 9) { found09 = true; } if (postingId == 8) { found08 = true; } } Assert.IsTrue(found10 && found09 && found08); }