Archive Calendar for GraffitiCMS now resets stats

After a while of using my archive calendar, the statistics for page views were starting to get really skewed in favor of the archive "post". It finally got to the point where the graph that's displayed under the Reporting tab in the Graffiti control panel had a line for archive that was 5 times longer than the nearest "real" post. Since the information about the number of people using the archive system is not that interesting to me, it was time to do something about it.

A bit of research later led me to the PostStatistic class in Graffiti.Core, in particular the Destroy() method. Since I wanted to have the ability to turn on or off the resetting of the archive stats, I decided to make the reset a Chalk extension. This meant it would become a method in my JmbCalendarHelper extension:

    public static void ResetArchivePageStatistics() {
      GraffitiContext gc = GraffitiContext.Current;
      Post post = gc["post"] as Post;
      if ((post != null) && (string.Compare(post.Name, "archive", true)) == 0){
        PostStatistic.Destroy(PostStatistic.Columns.PostId, post.Id);
      }
    }

Note that I was very careful to ensure that the post was really the archive post. Paranoid, moi? I didn't want to inadvertently reset the stats for another of my posts by mistake.

After that I added this line to the top of my cd:archive.view file:

$JmbCalendarHelper.ResetArchivePageStatistics()

so that the stats for the archive post would be reset every time the Archive Calendar system was used. In essence, they would always be zero.

I've updated the Archive Calendar page on CodePlex with this new release (v1.01).

Album cover for The Best of The Monkees Now playing:
The Monkees - Daydream Believer
(from The Best of The Monkees)



Posts on similar topics...

No Responses

Feel free to add a comment...

Leave a Response

Some MarkDown is allowed, but HTML is not. (Click to learn more.)

  • Emphasize with italics: surround word with underscores _emphasis_
  • Emphasize strongly: surround word with double-asterisks **strong**
  • Inline code: surround text with backticks `IEnumerable`
  • Unordered list: start each line with an asterisk, space * an item
  • Ordered list: start each line with a digit, period, space 1. an item
  • Insert code block: start each line with four spaces
  • Insert blockquote: start each line with right-angle-bracket, space > Now is the time...

Search

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.

Validation

Validate markup as HTML5 (beta)     Validate CSS

Bottom swirl

Archives

February 2012 (6)
SMTWTFS
« Jan  
1234
567891011
12131415161718
19202122232425
26272829

Like this Archive Calendar widget? Download it here.

Social networking

Google ads

The OUT Campaign

The OUT Campaign

My Tweets

  • LOL! RT @secretGeek: Watching the NoCss movement gain momentum
  • Blog post: More on caring less about clichés, or not http://t.co/P1Unt4y9
  • @peterritchie Oh my god, the HAIR! It's all over his head! Ewwww. /cc @MillerMark
Bottom swirl