Commits

Marcin Kuzminski committed d439d40

Update last_change from VCS data on request.
- lightweight dashboard shows now last_date also taken from db and it is fast !

  • Participants
  • Parent commits 62e493c

Comments (0)

Files changed (5)

File rhodecode/controllers/home.py

                 template.get_def("repo_name")
                 .render(name, rtype, private, fork_of, short_name=False,
                         admin=False, _=_, h=h, c=c))
+            last_change = lambda last_change:  (template.get_def("last_change")
+                                           .render(last_change, _=_, h=h, c=c))
             rss_lnk = lambda repo_name: (template.get_def("rss")
                                            .render(repo_name, _=_, h=h, c=c))
             atom_lnk = lambda repo_name: (template.get_def("atom")
                     "raw_name": repo.repo_name.lower(),
                     "name": repo_lnk(repo.repo_name, repo.repo_type,
                                      repo.private, repo.fork),
-                    "last_change": h.age(repo.last_db_change),
+                    "last_change": last_change(repo.last_db_change),
                     "desc": repo.description,
                     "owner": h.person(repo.user.username),
                     "rss": rss_lnk(repo.repo_name),

File rhodecode/lib/base.py

 
             dbr = c.rhodecode_db_repo = Repository.get_by_repo_name(c.repo_name)
             c.rhodecode_repo = c.rhodecode_db_repo.scm_instance
-
+            # update last change according to VCS data
+            dbr.update_last_change(c.rhodecode_repo.last_change)
             if c.rhodecode_repo is None:
                 log.error('%s this repository is present in database but it '
                           'cannot be created as an scm instance', c.repo_name)

File rhodecode/model/db.py

         cs = self.get_changeset(self.landing_rev) or self.get_changeset()
         return cs
 
+    def update_last_change(self, last_change=None):
+        if last_change is None:
+            last_change = datetime.datetime.now()
+        if self.updated_on is None or self.updated_on != last_change:
+            log.debug('updated repo %s with new date %s' % (self, last_change))
+            self.updated_on = last_change
+            Session().add(self)
+            Session().commit()
+
     @property
     def tip(self):
         return self.get_changeset('tip')

File rhodecode/templates/data_table/_dt_elements.html

   </div>
 </%def>
 
-
+<%def name="last_change(last_change)">
+  <span class="tooltip" date="${last_change}" title="${h.tooltip(h.fmt_date(last_change))}">${h.age(last_change)}</span>
+</%def>
 
 <%def name="revision(name,rev,tip,author,last_msg)">
   <div>

File rhodecode/templates/index_base.html

                     </td>
                     ##LAST CHANGE DATE
                     <td>
-                      <span class="tooltip" date="${repo['last_change']}" title="${h.tooltip(h.fmt_date(repo['last_change']))}">${h.age(repo['last_change'])}</span>
+                      ${dt.last_change(repo['last_change'])}
                     </td>
                     ##LAST REVISION
                     <td>
                {key:"raw_name"},
                {key:"name"},
                {key:"desc"},
-               //{key:"last_change"},
+               {key:"last_change"},
                {key:"owner"},
                {key:"rss"},
                {key:"atom"},
             {key:"name",label:"${_('Name')}",sortable:true,
                 sortOptions: { sortFunction: nameSort }},
             {key:"desc",label:"${_('Description')}",sortable:true},
-            //{key:"last_change",label:"${_('Last Change')}",sortable:true,
-            //    sortOptions: { sortFunction: ageSort }},
+            {key:"last_change",label:"${_('Last Change')}",sortable:true,
+                sortOptions: { sortFunction: ageSort }},
             {key:"owner",label:"${_('Owner')}",sortable:true},
             {key:"rss",label:"",sortable:false},
             {key:"atom",label:"",sortable:false},