freedomofpress / securethenews

An automated scanner and web dashboard for tracking TLS deployment across news organizations
https://securethe.news
GNU Affero General Public License v3.0
102 stars 25 forks source link

Store BlogPost preview in the database #98

Open garrettr opened 7 years ago

garrettr commented 7 years ago

Currently, the preview blurb displayed for each BlogPost on the BlogIndexPage is re-computed every time the page is loaded (since it is an @property attribute on the model). It would be better to memoize this computation and only store it when the BlogPost changes. The easiest way to do this is to add a preview field to BlogPost and use a custom save method to compute and save the preview only when necessary.