'Return a human-readable name for an ad given its codename.
Optionally, a dictionary of things can be passed in so lookups can
be done in batch upstream.'

@staticmethod
def get_ad_name(code, things=None):

    if (not things):
        things = AdvertTrafficSummary.get_things([code])
    thing = things.get(code)
    campaign = None
    if (not thing):
        (fullname, campaign) = AdvertTrafficSummary.split_codename(code)
        thing = things.get(fullname)
    if (not thing):
        if code.startswith('dart_'):
            srname = code.split('_', 1)[1]
            srname = AdvertTrafficSummary.get_sr_name(srname)
            return ('DART:    ' + srname)
        else:
            return code
    elif isinstance(thing, Link):
        return ('Link:    ' + thing.title)
    elif isinstance(thing, Subreddit):
        srname = AdvertTrafficSummary.get_sr_name(thing.name)
        name = ('300x100:    ' + srname)
        if campaign:
            name += ('    (%s)' % campaign)
        return name
