Skip to content

Instantly share code, notes, and snippets.

@bplexico
Created July 15, 2013 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bplexico/6003347 to your computer and use it in GitHub Desktop.
Save bplexico/6003347 to your computer and use it in GitHub Desktop.
after refactoring assignments
def add_uncategorized
# Support for uncategorized topics
uncategorized_topics = get_uncategorized_topics
if uncategorized_topics.present?
totals = get_topic_totals
uncategorized = get_uncategorized_category
# Find the appropriate place to insert it:
insert_at = nil
@categories.each_with_index do |c, idx|
if (uncategorized.topics_week || 0) > (c.topics_week || 0)
insert_at = idx
break
end
end
@categories.insert(insert_at || @categories.size, uncategorized)
end
if @all_topics.present? && uncategorized.present?
uncategorized.displayable_topics = uncategorized_topics
@all_topics << uncategorized_topics
@all_topics.flatten!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment