Writing an Archive Calendar, part 4a

OK the first bug I reported to myself in the previous post was trivial to fix. I changed the PostReader class to add a couple of new methods GetFilteredPostsForMonth():

    public static PostCollection GetFilteredPostsForMonth(int year, int month) {
      return GetFilteredPostsForDate(year, month, 0);
    }

and GetFilteredPostsForDate():

    public static PostCollection GetFilteredPostsForDate(int year, int month, int day) {
      PostCollection posts = GetPostsForDate(year, month, day);
      PostCollection filteredPosts = new PostCollection();
      foreach (Post post in posts) {
        if (RolePermissionManager.GetPermissions(post.CategoryId, GraffitiUsers.Current).Read)
          filteredPosts.Add(post);
      }
      return filteredPosts;
    }

Notice that what gets cached is the complete set of posts for the period (it's done in GetPostsForDate()), not the filtered set.

And then I changed the Chalk-visible GetPostsForMonth() and the GetPostsForDay() methods to call these new internal methods instead.

    public PostCollection GetPostsForMonth(string yearAsString, string monthAsString) {
      int year, month;
      GetDateParts(yearAsString, monthAsString, out year, out month);
      return PostsReader.GetFilteredPostsForMonth(year, month);
    }

    public PostCollection GetPostsForDay(string yearAsString, string monthAsString, string dayAsString) {
      int year, month, day;
      GetDateParts(yearAsString, monthAsString, dayAsString, out year, out month, out day);
      return PostsReader.GetFilteredPostsForDate(year, month, day);
    }

Done.

Now, onto paging...

(Part 1 is here, part 2 here, part 3 here, part 4 here, part 4a here, part 4b here.)

Now playing:
Pet Shop Boys - In the Night
(from Further listening 1984-1986)



Posts on similar topics...

Share it: Digg It!  StumbleUpon  Reddit  Del.icio.us  NewsVine  Furl  BlinkList  Ma.gnolia  Technorati

1 Response

  • Sat 17 Jan 2009
  • 7:26 PM
  •  avatar #1

Dew Drop – January 17, 2009 | Alvin Ashcraft's Morning Dew said...

Pingback from Dew Drop – January 17, 2009 | Alvin Ashcraft's Morning Dew

Leave a Response

About Me

I'm Julian M Bucknall, the M because it's my middle initial and because I and the other Julian Bucknall (the movie guy) would like to differentiate ourselves.

I'm a programmer by trade, an actor by ambition, and an algorithms guy by osmosis. I write articles for PCPlus in my spare time, not that there's much of that.

Julian M Bucknall Apart from that, an ex-pat Brit, atheist, microbrew enthusiast, Pet Shop Boys fanboy, slide rule and HP calculator collector, amateur photographer, Altoids muncher.

DevExpress

I'm Chief Technology Officer at Developer Express, a software company that writes some great controls and tools for .NET and Delphi. I'm responsible for the technology oversight and vision of the company.

The OUT Campaign

The OUT Campaign

Validation

Valid XHTML 1.0 Transitional     Valid CSS!

Bottom swirl

Archives

February 2010 (2)
SMTWTFS
« Jan  
123456
78910111213
14151617181920
21222324252627
28

Like this Archive Calendar widget? Download it here.

Search

Google ads

My Tweets

  • It seems replacing all our windows will take a mere couple of days. Next Monday/Tuesday will be interesting: it'll drive me crazy.
  • Every now and then, you have a day where nothing goes right. That was today. Bah.
  • White paper written. Now to write the exemplar application
Bottom swirl