diff rhodecode/controllers/summary.py @ 1244:0eceb478c720 beta

fixed issue #165 trending source files are now stored in cache as ext only, and translated to description only when displaying, so future changes of mappings will take affect right away. Also changes the way how map is generating, ie. autogenerate from pygments lexers, and than complete with user defined mappings.
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 11 Apr 2011 22:24:04 +0200
parents 50e41777675d
children 13b507b73190
line wrap: on
line diff
--- a/rhodecode/controllers/summary.py	Sun Apr 10 23:34:28 2011 +0200
+++ b/rhodecode/controllers/summary.py	Mon Apr 11 22:24:04 2011 +0200
@@ -41,7 +41,8 @@
 from rhodecode.lib.utils import OrderedDict, EmptyChangeset
 
 from rhodecode.lib.celerylib import run_task
-from rhodecode.lib.celerylib.tasks import get_commits_stats
+from rhodecode.lib.celerylib.tasks import get_commits_stats, \
+    LANGUAGES_EXTENSIONS_MAP
 from rhodecode.lib.helpers import RepoPage
 
 try:
@@ -131,8 +132,14 @@
             lang_stats = json.loads(stats.languages)
             c.commit_data = stats.commit_activity
             c.overview_data = stats.commit_activity_combined
+
+            lang_stats = [(x, {"count":y,
+                               "desc":LANGUAGES_EXTENSIONS_MAP.get(x)})
+                          for x, y in lang_stats.items()]
+            print lang_stats
+
             c.trending_languages = json.dumps(OrderedDict(
-                                       sorted(lang_stats.items(), reverse=True,
+                                       sorted(lang_stats, reverse=True,
                                             key=lambda k: k[1])[:10]
                                         )
                                     )