示例#1
0
 def GET(self, id=None, format='json'):
     if id:
         if id.startswith("/"):
             id = id[1:]
         id = unquote(id)
         #if id.find("%3A") != -1:
         #    id = ":".join(id.split("%3A"))
         params = {'pid': id}
         params['label'] = titlelookup(id)
         params['dlist'], params['dates'], params['total'] = item_stats(
             id, r)
         if params['dlist']:
             params['sparkline_url'] = get_dateline_url(
                 params['dlist'], params['dates'])
         else:
             params[
                 'sparkline_url'] = "http://ora.ouls.ox.ac.uk/ora_logo.png"
         params['entities'] = get_entities_in_pid(id, r)
         options = web.input()
         if 'geo' in options:
             params['geousage_url'] = get_gchart_map_for_pid(id, r)
         format = options.get('format', format)
         if format == "html":
             return render.item(**params)
         return simplejson.dumps(params)
     else:
         return render.item_form()
示例#2
0
def print_entity_report(phrase, r, gen_charts):
  print "%s = %s - %s, %s, %s" % entity_lookup(phrase, r)
  print "Entity %s found in the following items" % (phrase)
  for title, pid in entity_found_in_items(phrase, r):
    print '"%s" - %s' % (title, pid)
    if gen_charts:
      print "Geo-breakdown (yellow -> red) %s" % get_gchart_map_for_pid(pid, r)
示例#3
0
def print_item_stats(pid,r,gen_charts=False):
  dlist, dates, total = item_stats(pid, r)
  print "Results for %s" % pid
  print "Title: %s" % titlelookup(pid)
  print "Totals - Views: %(v)s, Downloads: %(d)s, Other: %(o)s" % total
  print "Breakdown:"
  for date in dlist:
    print "%s" % date + " - Views: %(v)s, Downloads: %(d)s, Other: %(o)s" % dates[date]
  if gen_charts:
    print "Google Chart url for the user breakdown - (Red - heaviest usage, yellow - weakest)"
    print "%s" % get_gchart_map_for_pid(pid, r)
    print "Google Sparkline for item activity"
    print get_dateline_url(dlist, dates)
示例#4
0
 def GET(self, id = None, format = 'json'):
     if id:
         if id.startswith("/"):
             id = id[1:]
         id = unquote(id)
         #if id.find("%3A") != -1:
         #    id = ":".join(id.split("%3A"))
         params = {'pid':id}
         params['label'] = titlelookup(id)
         params['dlist'], params['dates'], params['total'] = item_stats(id, r)
         if params['dlist']:
             params['sparkline_url'] = get_dateline_url(params['dlist'], params['dates'])
         else:
             params['sparkline_url'] = "http://ora.ouls.ox.ac.uk/ora_logo.png"
         params['entities'] = get_entities_in_pid(id, r)
         options = web.input()
         if 'geo' in options:
             params['geousage_url'] = get_gchart_map_for_pid(id, r)
         format = options.get('format', format)
         if format == "html":
             return render.item(**params)
         return simplejson.dumps(params)
     else:
         return render.item_form()
示例#5
0
      print "Generating geo charts"
      gen_charts = True
    else:
      phrase_tokens.append(argv)

  phrase = " ".join(phrase_tokens)

  if phrase in prefixes:
    if csvfile:
      save_set(phrase, r, limit, startswith, csvfile, verbose=True)
    else:
      print_browse_set(phrase, r, limit, startswith)
  elif phrase.count(":") == 1:
    if phrase.startswith("uuid") or phrase.startswith("ora"):
      print_item_stats(phrase, r, gen_charts)
    else:
      print_entity_report(phrase, r, gen_charts)
  else:
    print "Trying to find freetext %s" % phrase
    for tagtype in prefixes:
      tag = entity_existence(phrase, tagtype, r)
      if tag  and (limit == 0 or combined_count(r.get("t:views:%s" % tag), r.get("t:dls:%s" % tag)) > limit):
        print "Found %s (type: %s) for %s" % (tag, tagtype, phrase)
        print "Views: %s, Downloads: %s, Other: %s" % (r.get("t:views:%s" % tag), r.get("t:dls:%s" % tag), r.get("t:other:%s" % tag))
        print "Entity %s(in %s) found in the following items" % (phrase, tagtype)
        for pid in (r.smembers("e:%s" % tag) or []):
          print '"%s" - %s' % (titlelookup(pid), pid)
          if gen_charts:
            print "Geo-breakdown (yellow -> red) %s" % get_gchart_map_for_pid(pid, r)
        print "------------------------------------------------------"