def link_project(self, mproject):
     """
     Loads in the commits from a project and then attempts to place new entires in the
     user_corporation_project table (aka ProjectInvolvement) table.
     
     @param mproject: a dbobjects.MasterProject element to load the data for
     """
     # FIXME: this currently has no support for hierarchical master projects
     projects = Project.select(Project.q.masterProjectID == mproject.id) # pylint: disable-msg=E1101
     
     # we'll need this for building SQL queries
     projarr = [x.id for x in projects]
     
     # get the first commit on the project so we know what month to start pumping data at
     firstcommit = CVSCommit.select(AND(CVSCommit.q.startDate > datetime.datetime(1997, 11, 01), # pylint: disable-msg=E1101
                                        IN(CVSCommit.q.projectID, projarr))).min(CVSCommit.q.startDate) # pylint: disable-msg=E1101
                                        
     lastcommit = CVSCommit.select(AND(CVSCommit.q.startDate > datetime.datetime(1997, 11, 01), # pylint: disable-msg=E1101
                                       IN(CVSCommit.q.projectID, projarr))).max(CVSCommit.q.startDate) # pylint: disable-msg=E1101
     if firstcommit == None:
         # do something here to indicate that it couldn't process this time period
         self.log.info("Project %s (id=%s) does not appear to have any commits in the window", mproject.name, mproject.id)
         return
                                    
     self.log.info("%s - %s %s", mproject.name, firstcommit, lastcommit)
     
     # iterate on a monthly basis across the data so we have monthly snapshots, just as we do for Eclipse
     currentdate = datetime.datetime(firstcommit.year, firstcommit.month, 1)
     nextdate = add_month(currentdate)
     while currentdate < lastcommit:
         self.link_project_month(mproject, projarr, currentdate, nextdate)
         currentdate = nextdate
         nextdate = add_month(currentdate)
Exemplo n.º 2
0
def get_project(projectname, masterproject, repopath):
    """
    Gets a project from the database
    
    @param projectname: name of the project
    @param masterproject: parent of the project
    @param repopath: path of the project
    """
    if not PROJECT_CACHE.has_key(masterproject.id):
        PROJECT_CACHE[masterproject.id] = {}
    if PROJECT_CACHE[masterproject.id].has_key(projectname):
        return PROJECT_CACHE[masterproject.id][projectname]
    
    project = Project.select(AND(Project.q.name == projectname,
                                Project.q.masterProjectID == masterproject.id))
    if project.count():
        PROJECT_CACHE[masterproject.id][projectname] = project[0]
    else:
        PROJECT_CACHE[masterproject.id][projectname] = Project(name=projectname, masterProject=masterproject, path=repopath)
    return PROJECT_CACHE[masterproject.id][projectname]