Changeset - d439d408b415
[Not reviewed]
beta
0 5 0
Marcin Kuzminski - 13 years ago 2012-10-18 20:54:25
marcin@python-works.com
Update last_change from VCS data on request.
- lightweight dashboard shows now last_date also taken from db and it is fast !
5 files changed with 21 insertions and 7 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/home.py
Show inline comments
 
@@ -70,6 +70,8 @@ class HomeController(BaseController):
 
                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")
 
@@ -81,7 +83,7 @@ class HomeController(BaseController):
 
                    "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),
rhodecode/lib/base.py
Show inline comments
 
@@ -307,7 +307,8 @@ class BaseRepoController(BaseController)
 

	
 
            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)
rhodecode/model/db.py
Show inline comments
 
@@ -874,6 +874,15 @@ class Repository(Base, BaseModel):
 
        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')
rhodecode/templates/data_table/_dt_elements.html
Show inline comments
 
@@ -82,7 +82,9 @@
 
  </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>
rhodecode/templates/index_base.html
Show inline comments
 
@@ -98,7 +98,7 @@
 
                    </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>
 
@@ -232,7 +232,7 @@
 
               {key:"raw_name"},
 
               {key:"name"},
 
               {key:"desc"},
 
               //{key:"last_change"},
 
               {key:"last_change"},
 
               {key:"owner"},
 
               {key:"rss"},
 
               {key:"atom"},
 
@@ -264,8 +264,8 @@
 
            {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},
0 comments (0 inline, 0 general)