@task
@timeit
def add_short_links(doc_ids):
 base_url = 'https://{0}%s'.format(Site.objects.get_current().domain)
 docs = Document.objects.filter(id__in=doc_ids)
 try:
  pin_this_thread()
  for doc in docs:
   endpoint = django_reverse('wiki.document', args=[doc.slug])
   doc.update(share_link=generate_short_url((base_url % endpoint)))
   statsd.incr('wiki.add_short_links.success')
 except BitlyRateLimitException:
  statsd.incr('wiki.add_short_links.rate_limited')
  pass
 finally:
  unpin_this_thread()

@ task @ timeit def add_short_links ( doc_ids ) : base_url = 'https://{0}%s' . format ( Site . objects . get_current ( ) . domain ) docs = Document . objects . filter ( id__in = doc_ids ) try : pin_this_thread ( ) for doc in docs : endpoint = django_reverse ( 'wiki.document' , args = [ doc . slug ] ) doc . update ( share_link = generate_short_url ( ( base_url % endpoint ) ) ) statsd . incr ( 'wiki.add_short_links.success' ) except BitlyRateLimitException : statsd . incr ( 'wiki.add_short_links.rate_limited' ) pass finally : unpin_this_thread ( )
create short_urls for a list of docs .