100% completeness-fu

Posted: September 23rd, 2009 | Author: Josh Kalderimis | Filed under: Open Source Projects, Rails, Ruby, Web Development | Tags: , , | 4 Comments »

The age of completeness-fu is upon us!

Sometimes validations just don’t cut the mustard and all you want to do is to grade an instance based on how complete its information is. For example, a Location has a title and a description but no address, thus its only 60% complete. Or maybe title is worth more than description and address so its 80% complete. Whatever the case, this is not a new problem and recreating the wheel is a bit unnecessary, so welcome to completeness-fu.

The dsl is based on the thinking-sphinx configuration, which is nice, clean and simple, but very effective.

Here is a sample of the config code used to define a set of checks for a completeness score:

define_completeness_scoring do
  check :title,       lambda { |per| per.title.present? },  :high
  check :description, lambda { |per| per.description.present? }, :medium
  check :main_image,  lambda { |per| per.main_image? },     :low
end

It still needs some more tlc, but its a nice start and a simple solution for a common problem.

So please, have a play around with it, fork the code, make some improvements/enhancements and let me know what you think.


4 Comments on “100% completeness-fu”

  1. 1 Guoliang Cao said at 15:35 on September 25th, 2009:

    Interesting idea. What can I do with the scores?

  2. 2 Josh Kalderimis said at 21:43 on September 26th, 2009:

    The idea is more about information enrichment instead of validation. Validations are about formatting and right or wrong information, but enrichment or ‘completeness’ is about how much information you have.

    For example, think about a user profile on LinkedIn or other social networking sites, if you don’t fill in much information, maybe just your name and age, then you have a low completeness score, but if you fill in more then your profile is more complete and maybe you can do more because you are seen as more ‘trusted’.

    We use this for an events website which wants to import lots of information with variable quality. If we grade the imported information we can then prompt for enrichment, which is better than just rejecting the information.

    Thanks for the comment, this has prompted me to add a better example and explanation to the github readme.

    I hope this helps.

    Josh

  3. 3 Jim Hoskins said at 19:30 on September 28th, 2009:

    More information on the completeness pattern can be found here: http://ui-patterns.com/pattern/CompletenessMeter

  4. 4 Peter Berkenbosch said at 14:30 on October 13th, 2009:

    Had an issue with the failed_checks method when using a symbol to a method. I fixed it in my fork.

    Thanks for the great gem!


Leave a Reply