Ñò
84åLc           @   sx   d  d k  l Z d  d k l Z d  d k l Z d  d k l Z d  d k l	 Z	 d „  Z
 d „  Z d „  Z d	 „  Z d
 S(   iÿÿÿÿ(   t   User(   t   settings(   t   cache(   t
   iri_to_uri(   t   group_by_sortc          C   sÚ   d }  t  i |  ƒ } | d j o´ t t i i d d ƒ d d g ƒ t i  } t t i i d d ƒ d d g ƒ t i  } t t i i d d ƒ d d g ƒ t i  } t	 d | | | ƒ } t  i
 |  | t i d ƒ n | S(   sc   
    Generate the top contributor stats to be displayed for an entire
    Pootle installation.
    s   /:gentopstatst   pootleprofile__suggestert   usernamet   pootleprofile__reviewert   pootleprofile__submissioni   N(   R   t   gett   NoneR   R    t   objectst   excludeR   t   TOPSTAT_SIZEt   mapt   sett   CACHE_MIDDLEWARE_SECONDS(   t   keyt   resultt   top_suggt
   top_reviewt   top_sub(    (    s8   /var/www/Pootle/local_apps/pootle_app/views/top_stats.pyt   gentopstats_root   s    c         C   sç   t  d |  i ƒ } t i | ƒ } | d
 j o´ t t i i d |  ƒ d d g ƒ t	 i
  } t t i i d |  ƒ d d g ƒ t	 i
  } t t i i d |  ƒ d d g ƒ t	 i
  } t d
 | | | ƒ } t i | | t	 i d	 ƒ n | S(   sq  Generate the top contributor stats to be displayed
    for an entire Pootle installation, a language or a project.
    The output of this function looks something like this:
      {'data':        [],
       'headerlabel': u'Suggestions'},
      {'data':        [],
       'headerlabel': u'Reviews'},
      {'data':        [],
       'headerlabel': u'Submissions'}]
    s   %s:gentopstatst7   pootleprofile__suggester__translation_project__languageR   R   t6   pootleprofile__reviewer__translation_project__languageR   t8   pootleprofile__submission__translation_project__languageR   i   N(   R   t   pootle_pathR   R	   R
   R   R    R   t   filterR   R   R   R   R   (   t   languageR   R   R   R   R   (    (    s8   /var/www/Pootle/local_apps/pootle_app/views/top_stats.pyt   gentopstats_language/   s    c         C   sç   t  d |  i ƒ } t i | ƒ } | d
 j o´ t t i i d |  ƒ d d g ƒ t	 i
  } t t i i d |  ƒ d d g ƒ t	 i
  } t t i i d |  ƒ d d g ƒ t	 i
  } t d
 | | | ƒ } t i | | t	 i d	 ƒ n | S(   sq  Generate the top contributor stats to be displayed
    for an entire Pootle installation, a language or a project.
    The output of this function looks something like this:
      {'data':        [],
       'headerlabel': u'Suggestions'},
      {'data':        [],
       'headerlabel': u'Reviews'},
      {'data':        [],
       'headerlabel': u'Submissions'}]
    s   %s:gentopstatst6   pootleprofile__suggester__translation_project__projectR   R   t5   pootleprofile__reviewer__translation_project__projectR   t7   pootleprofile__submission__translation_project__projectR   i   N(   R   R   R   R	   R
   R   R    R   R   R   R   R   R   R   (   t   projectR   R   R   R   R   (    (    s8   /var/www/Pootle/local_apps/pootle_app/views/top_stats.pyt   gentopstats_projectH   s    c         C   sã   t  d |  i ƒ } t i | ƒ } | d	 j o° t t i i d |  ƒ d d g ƒ t	 i
  } t t i i d |  ƒ d d g ƒ t	 i
  } t t i i d |  ƒ d d g ƒ t	 i
  } t d	 | | | ƒ } t i | | t	 i ƒ n | S(
   sq  Generate the top contributor stats to be displayed
    for an entire Pootle installation, a language or a project.
    The output of this function looks something like this:
      {'data':        [],
       'headerlabel': u'Suggestions'},
      {'data':        [],
       'headerlabel': u'Reviews'},
      {'data':        [],
       'headerlabel': u'Submissions'}]
    s   %s:gentopstatst-   pootleprofile__suggester__translation_projectR   R   t,   pootleprofile__reviewer__translation_projectR   t.   pootleprofile__submission__translation_projectR   N(   R   R   R   R	   R
   R   R    R   R   R   R   R   R   R   (   t   translation_projectR   R   R   R   R   (    (    s8   /var/www/Pootle/local_apps/pootle_app/views/top_stats.pyt   gentopstats_translation_projecta   s    N(   t   django.contrib.auth.modelsR    t   django.confR   t   django.core.cacheR   t   django.utils.encodingR   t   pootle_misc.aggregateR   R   R   R"   R'   (    (    (    s8   /var/www/Pootle/local_apps/pootle_app/views/top_stats.pyt   <module>   s   			