private static ScheduledTask CreateTaskWithUniqueId(ScheduledTasks tasks, ScheduledOperation operation) { var taskId = 0; while (taskId < tasks.Count && taskId == tasks[taskId].Id) { taskId++; } var task = new ScheduledTask(taskId, operation); return(task); }
private void ScheduleLikesForFollowee(long now, RandomLikeAutomatonData data, ScheduledTasks tasks, string userId, List <TweetData> tweets) { for (var i = 0; i < tweets.Count; i++) { if (data.PercentageLikeChance > _random.Next(1) && data.LikesGivenPerFollowee[userId] < data.MaxLikesPerFollowee[userId]) { var operation = new ScheduledOperation(DateTimeOffset.FromUnixTimeSeconds(now + _random.Next(SecondsPerHour * 2)), _like.Name, tweets[i].Id.ToString()); tasks.Add(CreateTaskWithUniqueId(tasks, operation)); data.LikesGivenPerFollowee[userId]++; } } }
public ScheduledTask(int id, ScheduledOperation operation) : this(id, new List <ScheduledOperation>() { operation }) { }