Changeset - a3efaaa6ed4f
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 14 years ago 2012-01-12 23:18:10
marcin@python-works.com
fixes issue #271
- OrderedDict serialization sometimes failed due to how odict is implemented. Dropped usage of it for a simple tuple
3 files changed with 18 insertions and 16 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/summary.py
Show inline comments
 
@@ -154,11 +154,9 @@ class SummaryController(BaseRepoControll
 
                               "desc": LANGUAGES_EXTENSIONS_MAP.get(x)})
 
                          for x, y in lang_stats_d.items())
 

	
 
            c.trending_languages = json.dumps(OrderedDict(
 
                                       sorted(lang_stats, reverse=True,
 
                                            key=lambda k: k[1])[:10]
 
                                        )
 
                                    )
 
            c.trending_languages = json.dumps(
 
                sorted(lang_stats, reverse=True, key=lambda k: k[1])[:10]
 
            )
 
            last_rev = stats.stat_on_revision + 1
 
            c.repo_last_rev = c.rhodecode_repo.count()\
 
                if c.rhodecode_repo.revisions else 0
rhodecode/lib/compat.py
Show inline comments
 
@@ -87,6 +87,7 @@ class _Nil(object):
 

	
 
_nil = _Nil()
 

	
 

	
 
class _odict(object):
 
    """Ordered dict data structure, with O(1) complexity for dict operations
 
    that modify one element.
 
@@ -146,7 +147,7 @@ class _odict(object):
 
        dict_impl = self._dict_impl()
 
        try:
 
            dict_impl.__getitem__(self, key)[1] = val
 
        except KeyError, e:
 
        except KeyError:
 
            new = [dict_impl.__getattribute__(self, 'lt'), val, _nil]
 
            dict_impl.__setitem__(self, key, new)
 
            if dict_impl.__getattribute__(self, 'lt') == _nil:
 
@@ -158,7 +159,7 @@ class _odict(object):
 

	
 
    def __delitem__(self, key):
 
        dict_impl = self._dict_impl()
 
        pred, _ , succ = self._dict_impl().__getitem__(self, key)
 
        pred, _, succ = self._dict_impl().__getitem__(self, key)
 
        if pred == _nil:
 
            dict_impl.__setattr__(self, 'lh', succ)
 
        else:
 
@@ -351,6 +352,7 @@ class _odict(object):
 
                       dict_impl.__getattribute__(self, 'lt'),
 
                       dict_impl.__repr__(self))
 

	
 

	
 
class OrderedDict(_odict, dict):
 

	
 
    def _dict_impl(self):
rhodecode/templates/summary/summary.html
Show inline comments
 
@@ -295,33 +295,35 @@ YUE.on(['download_options','archive_subr
 
var data = ${c.trending_languages|n};
 
var total = 0;
 
var no_data = true;
 
for (k in data){
 
    total += data[k].count;
 
    no_data = false;
 
}
 
var tbl = document.createElement('table');
 
tbl.setAttribute('class','trending_language_tbl');
 
var cnt = 0;
 
for (k in data){
 

	
 
for (var i=0;i<data.length;i++){
 
    total += data[i][1].count;    
 
    cnt += 1;
 
    no_data = false;
 
    
 
    var hide = cnt>2;
 
    var tr = document.createElement('tr');
 
    if (hide){
 
        tr.setAttribute('style','display:none');
 
        tr.setAttribute('class','stats_hidden');
 
    }
 
    var percentage = Math.round((data[k].count/total*100),2);
 
    var value = data[k].count;
 
    var k = data[i][0];
 
    var obj = data[i][1];
 
    var percentage = Math.round((obj.count/total*100),2);
 
    
 
    var td1 = document.createElement('td');
 
    td1.width = 150;
 
    var trending_language_label = document.createElement('div');
 
    trending_language_label.innerHTML = data[k].desc+" ("+k+")";
 
    trending_language_label.innerHTML = obj.desc+" ("+k+")";
 
    td1.appendChild(trending_language_label);
 

	
 
    var td2 = document.createElement('td');
 
    td2.setAttribute('style','padding-right:14px !important');
 
    var trending_language = document.createElement('div');
 
    var nr_files = value+" ${_('files')}";
 
    var nr_files = obj.count+" ${_('files')}";
 

	
 
    trending_language.title = k+" "+nr_files;
 

	
0 comments (0 inline, 0 general)