theforeman/foreman — pull request #1477 by nbarrientos (2014-05-26 10:34:24+00:00)
Title: Only call fact_name_class.maximum if necessary.

This patch stops calling fact_name_class.maximum every
time facts are uploaded, doing only the query when it's
strictly necessary (basically, when there are facts to create).

This optimization reduces the number of DB queries, which
might have a big impact when the size of the fact_names
table is significantly big.