mirror of https://gitlab.com/tildes/tildes.git
Browse Source
The creation of the Theme Previews page showed that the way I was doing metrics for database model objects being created wasn't very good. Whenever someone loaded the Theme Previews page, the "total topics" metric would increase by 2, "total comments" by 4, and "exemplary labels" by 1, because the page is creating that many fake objects and the metrics were being sent in each class's __init__ method. This changes to take advantage of SQLAlchemy's object lifecycle event for "pending to persistent", which only triggers when an object is actually persisted to the database. When this event happens, the object's _update_creation_metric method is called, and all metric updates have been moved into that method now.merge-requests/85/head
Deimos
5 years ago
9 changed files with 33 additions and 6 deletions
Loading…
Reference in new issue