Support for tags in code snippet API; tag namespaces; donation total per tag

* code_snippet API call accepts a 'tags' parameter
 * tags get included in the code snippet
 * we protect against Bobby Tables by whitelisting allowed characters in tags
* tags are organized into "namespaces", e.g. the tag "petition:123" is in tag namespace "petition"
 * later we can use this to report e.g. the top raising petitions
* we keep a running total (in redis) of how much has been raised in each tag.  this total is in the organization's preferred currency.
let's do that.

On Wed, Sep 24, 2014 at 12:43 PM, Jacinda Moore <notifications@github.com>
wrote:

> In app/models/tag_namespace.rb:
>
> > +  validates :namespace, presence: true
> > +  validates :organization, presence: true
> > +
> > +  has_many :tags, foreign_key: 'namespace_id'
> > +  belongs_to :organization
> > +
> > +  def self.find_or_create!(organization, name)
> > +    namespace = where(namespace: name, organization: organization).first
> > +    if namespace.nil?
> > +      namespace = TagNamespace.create!(namespace: name, organization: organization)
> > +    end
> > +    namespace
> > +  end
> > +
> > +  def most_raised_key
> > +    "most_raised_tags/#{namespace}"
>
> by 'weird things', i mean that the sorted set will be across
> organizations, rather than for one organization
> So we'll be able to get e.g. the top-raising petitions overall, but not
> per organization.
> This is fixable by making the redis key include the org slug, i think
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/controlshift/prague-server/pull/12/files#r17983181>.
>



-- 
--
This is my personal email address. If you are emailing me about
ControlShift, please send a note to nathan@controlshiftlabs.com