100% completeness-fu

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.

5 thoughts on “100% completeness-fu

    • 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

  1. My problem that my user profile is large, and hence is divided into multiple sections. I need to calculate the completeness score for individual sections along with a completeness score of full profile. I can’t figure out how should it be done. Please help .. Thanks in advance.

Comments are closed.