Created
January 6, 2011 22:15
-
-
Save ashaw/768708 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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