Skip to content

Commit

Permalink
Add extra fields to track the threadmark post number, since that's ne…
Browse files Browse the repository at this point in the history
…eded when

the actual posts are tallied up, as well as when loading pages.
Ensure posts prior to the last threadmarked post are not counted when tallying.
  • Loading branch information
Kinematics committed Apr 24, 2015
1 parent 9c634ac commit f1d8f78
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
8 changes: 5 additions & 3 deletions TallyCore/Adapters/XenForoAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ public async Task<int> GetStartingPostNumber(IPageProvider pageProvider, IQuest
if (pageProvider == null)
throw new ArgumentNullException(nameof(pageProvider));

quest.ThreadmarkPost = 0;

// Use the provided start post if we aren't trying to find the threadmarks.
if (!quest.CheckForLastThreadmark)
return quest.StartPost;
Expand All @@ -342,9 +344,9 @@ public async Task<int> GetStartingPostNumber(IPageProvider pageProvider, IQuest
int threadmarkPostNumber = GetPostNumberOfPost(threadmarkPost);

if (threadmarkPostNumber > 0)
return threadmarkPostNumber + 1;
else
return quest.StartPost;
quest.ThreadmarkPost = threadmarkPostNumber + 1;

return quest.FirstTallyPost;
}

#endregion
Expand Down
10 changes: 10 additions & 0 deletions TallyCore/Interfaces/IQuest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ public interface IQuest
/// </summary>
bool ReadToEndOfThread { get; }

/// <summary>
/// Store the found threadmark post number.
/// </summary>
int ThreadmarkPost { get; set; }

/// <summary>
/// Return either the StartPost or the ThreadmarkPost, depending on config.
/// </summary>
int FirstTallyPost { get; }

/// <summary>
/// Get the forum adapter needed to read results from the web site this
/// quest is for.
Expand Down
19 changes: 19 additions & 0 deletions TallyCore/Quest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,25 @@ public bool CheckForLastThreadmark
/// of the thread. This is done when the EndPost is 0.
/// </summary>
public bool ReadToEndOfThread => EndPost < 1;

/// <summary>
/// Property to store any found threadmark post number.
/// </summary>
public int ThreadmarkPost { get; set; } = 0;

/// <summary>
/// Return either the StartPost or the ThreadmarkPost, depending on config.
/// </summary>
public int FirstTallyPost
{
get
{
if (CheckForLastThreadmark && ThreadmarkPost > 0)
return ThreadmarkPost;
else
return StartPost;
}
}
#endregion


Expand Down
2 changes: 1 addition & 1 deletion TallyCore/VoteCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void TallyVotes(IQuest quest, List<HtmlDocument> pages)
where post != null
let postNumber = forumAdapter.GetPostNumberOfPost(post)
where forumAdapter.GetAuthorOfPost(post) != threadAuthor &&
postNumber >= quest.StartPost && (quest.ReadToEndOfThread || postNumber <= quest.EndPost)
postNumber >= quest.FirstTallyPost && (quest.ReadToEndOfThread || postNumber <= quest.EndPost)
select post;


Expand Down

0 comments on commit f1d8f78

Please sign in to comment.