Issue 1255 getmostviewed macro new datamodel updated sql

Updated the getMostViewed() macro and the sql.

Please check.