/** * This probably should be in the TweetStatModel. * */ public TweetStatModel GetStats() { var Now = DateTimeOffset.Now.ToUnixTimeSeconds(); var PreviousMinute = 60; var PreviousHour = (60 * 60); TwitterAPIDAO dao = new TwitterAPIDAO(); string command = "SELECT Count(*) AS total"; command += ", (SELECT SUM(`LIKE`) FROM tweets) AS 'totalLikes'"; command += ", (SELECT SUM(`reTweet`) FROM tweets) AS 'totalRetweets'"; command += ", (SELECT COUNT(*) FROM tweets WHERE hasEmoji = 1) AS 'totalEmojis'"; command += ", (SELECT COUNT(*) FROM tweets WHERE hasImage = 1) AS 'totalImages'"; command += ", (SELECT COUNT(*) FROM tweets WHERE hasUrl = 1) AS 'totalUrls'"; command += ", (SELECT COUNT(*) FROM tweets WHERE `date` >= (SELECT MAX(`date`) FROM tweets) - 1) AS 'lastSecond'"; command += ", (SELECT COUNT(*) FROM tweets WHERE `date` >= (SELECT MAX(`date`) FROM tweets) - " + PreviousMinute + ") AS 'lastMinute'"; command += ", (SELECT COUNT(*) FROM tweets WHERE `date` >= (SELECT MAX(`date`) FROM tweets) - " + PreviousHour + ") AS 'lastHour'"; command += "FROM tweets"; TweetStatModel tweetStats = dao.GetSingleObject(command); tweetStats.Emojis = EmojiModel.GetEmojis(); tweetStats.Hashtags = HashtagModel.GetHashtags(); tweetStats.Languages = LanguageModel.GetLanguages(); tweetStats.Mentions = MentionModel.GetMentions(); tweetStats.Urls = UrlModel.GetUrls(); return(tweetStats); }
public bool Update(MentionModel model) // update an existing record { MentionModel x = Read(model.uid); x = model; return(_db.SaveChanges() == 1); }
public bool Create(MentionModel model) // add a new record to the DBMS { _db.Mentions.Update(model); return(_db.SaveChanges() == 1); }
public void ProcessMention(MentionModel model) { var command = model.Map <MentionCommand>(); _commandPublisher.Publish(command); }