Hobby Project: Filter for Newest Articles

jessekphillips profile image Jesse Phillips ・1 min read

If you read my previous post which focused on test data for this functionality, you may find the effort disproportionate.


auto isNewerArticle(ArticleMe am, PullState ps) {
-    return null;
+    return am.id > ps.lastArticle;

That is the implementation. Given an article and the previous pull data, the newer articles are the ones with the greater ID number.

This assumes articles are given newest first and that article IDs are given increasingly. However if the first isn't true I won't have reason to attempt short circuit.

alias inPreviousPull = (x) => !x.isNewerArticle(lastPullState);


You won't find the above code in the changes, I've taken the unittest and pulled out the complete concept to save new articles.

If I abstract the dev api into a range, I'll be using a normal range sequence and combined with the components I've already tested.

What is miss here is storing and retrieval of this lastPullState.

I wrote the test first. I almost didn't because the implications was so simple, but it is good to see the test fail.

Posted on by:

jessekphillips profile

Jesse Phillips


Senior Quality Assurance (SDET) ¶ Avid hobby D programmer ¶ Telling people what to do because I am right.


Editor guide

I've realized that this approach for filtering is seriously flawed because of the unpublished. Can you figure it out?