Sort contributions search result
Benjamin Renard

Benjamin Renard commited on 2014-12-01 22:19:07
Showing 2 changed files, with 9 additions and 6 deletions.

... ...
@@ -180,7 +180,6 @@ show_contributions=function(group,contributor_email,contributions) {
180 180
   tbody.html('');
181 181
   if (!contributions) {
182 182
     contributions=group.contributionsByContributorEmail(contributor_email);
183
-    contributions.reverse();
184 183
   }
185 184
   _current_displayed_contributions=contributions;
186 185
   _current_displayed_contributions_group=group;
... ...
@@ -230,18 +230,22 @@ function Group(uuid,name,data) {
230 230
         ret.push(this.contributions[uuid]);
231 231
       }
232 232
     }
233
-    ret.sort(function(a,b) {
233
+    return this.sortContributionsByDate(ret);
234
+  }
235
+
236
+  this.sortContributionsByDate=function(contributions) {
237
+    contributions.sort(function(a,b) {
234 238
       if (a.date==b.date) {
235 239
         return 0;
236 240
       }
237 241
       else if(a.date<b.date) {
238
-        return -1;
242
+        return 1;
239 243
       }
240 244
       else {
241
-        return 1;
245
+        return -1;
242 246
       }
243 247
     });
244
-    return ret;
248
+    return contributions;
245 249
   }
246 250
 
247 251
   this.deletedContributionsByContributorEmail=function(email) {
... ...
@@ -345,7 +349,7 @@ function Group(uuid,name,data) {
345 349
         ret.push(this.contributions[uuid]);
346 350
       }
347 351
     }
348
-    return ret; 
352
+    return this.sortContributionsByDate(ret);
349 353
   }
350 354
   
351 355
   this.getContributionsByCategory=function (category) {
352 356