In theme.rb c’è
ChildTheme.where(parent_theme_id: theme_id).distinct.pluck(:child_theme_id), in cui distinct può essere rimosso grazie all’indice unico aggiunto in discourse/db/migrate/20170313192741_add_themes.rb: add_index :child_themes, [:parent_theme_id, :child_theme_id], unique: true.
Ciò significa che, per due child theme: ChildTheme1(id1, child_theme_id1, parent_them_id) e ChildTheme2(id2, child_theme_id2, parent_them_id), se child_theme_id1 == child_theme_id2, allora id1 = id2; altrimenti, [:parent_theme_id, :child_theme_id] non sarebbe unico. Di conseguenza, ChildTheme.where(parent_theme_id: theme_id).pluck(:child_theme_id) restituirà già child_theme_id unici, quindi non è necessario chiamare distinct. Possiamo rimuoverlo per migliorare le prestazioni.