Skip to content

Instantly share code, notes, and snippets.

@ashaw
Created January 6, 2011 22:15
Show Gist options
  • Save ashaw/768708 to your computer and use it in GitHub Desktop.
Save ashaw/768708 to your computer and use it in GitHub Desktop.
def overwrite_stat
return if %w[Page Referrer PixelPingStory TwitterStory FacebookFan TwitterFollower].include?(self.entity.type.to_s)
new_count = self.count
existing_stat = Kernel.const_get(self.entity.type.to_s).first.stats.where(:count_date => self.count_date)[0]
if existing_stat
self.id = existing_stat.id
reload
@new_record = false
self.count = new_count
errors.clear
self.save(false)
end
return true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment