コード例 #1
0
 def ok(self):
     project = ScrumblesObjects.Project()
     project.projectName = self.projectTitleEntry.get()
     self.validateName(project.projectName)
     try:
         if not self.isTest:
             self.dataBlock.addNewScrumblesObject(project)
         else:
             print('TESTMODE: self.dataBlock.addNewScrumblesObject(%s)' %
                   repr(project))
     except IntegrityError:
         logging.exception('ID Collision')
         project.projectID = ScrumblesObjects.generateRowID()
         self.dataBlock.addNewScrumblesObject(project)
     else:
         messagebox.showinfo('Info', 'New Item Successfully Created')
         self.exit()
コード例 #2
0
    def updateAllObjects(self):
        if self.firstLoad:
            time.sleep(1)
        self.isLoading = True
        funcStartTime = time.clock()

        self.conn.connect()
        self.users.clear()
        self.items.clear()
        self.projects.clear()
        self.comments.clear()
        self.tags.clear()
        self.sprints.clear()
        self.itemMap = {}
        self.sprintMap = {}
        self.commentMap = {}
        self.projectMap = {}
        self.userMap = {}
        #print('getting tables')
        loopStartTime = time.clock()
        userTable = self.conn.getData(Query.getAllUsers)
        itemTable = self.conn.getData(Query.getAllCards)
        projectTable = self.conn.getData(Query.getAllProjects)
        commentTable = self.conn.getData(Query.getAllComments)
        sprintTable = self.conn.getData(Query.getAllSprints)
        userToProjectRelationTable = self.conn.getData(Query.getAllUserProject)
        itemToProjectRelationTable = self.conn.getData(Query.getAllProjectItem)
        itemTimeLineTable = self.conn.getData('SELECT * FROM CardTimeLine')
        epicTable = self.conn.getData('SELECT * FROM EpicTable')

        self.conn.close()

        #print('Tables loaded in %fms' % ((time.clock()-loopStartTime)*1000) )

        loopStartTime = time.clock()
        #print('splicing vectors')

        timeLineMap = self.mapTimeline(itemTimeLineTable)
        epicMap = self.buildEpicMap(epicTable)
        for comment in commentTable:
            Comment = ScrumblesObjects.Comment(comment)
            self.comments.append(Comment)
            self.commentMap[Comment.commentID] = Comment
        #print('Comment List Built in %fms' % ((time.clock() - loopStartTime) * 1000))

        loopStartTime = time.clock()
        for item in itemTable:
            Item = ScrumblesObjects.Item(item)
            Item.listOfComments = [
                C for C in self.comments if C.commentItemID == Item.itemID
            ]
            self.applyItemLine(Item, timeLineMap)
            # try:
            #     Item.itemTimeLine = timeLineMap[Item.itemID]
            # except KeyError:
            #     timeLineMap = self.reloadTimeLineMap()
            if 'AssignedToSPrint' in Item.itemTimeLine:
                Item.itemTimeLine['AssignedToSprint'] = Item.itemTimeLine[
                    'AssignedToSPrint']
            #self.populateItemTimeLine(Item,timeLineMap)
            self.itemMap[Item.itemID] = Item
            self.items.append(Item)
        #print('Item List Built in %fms' % ((time.clock() - loopStartTime) * 1000))

        loopStartTime = time.clock()
        for I in self.items:
            if I.itemID in epicMap:  #epicMap[subitemID]->EpicID
                self.itemMap[epicMap[I.itemID]].subItemList.append(
                    I)  #itemMap[itemID]->Item
        #print('Item subitems spliced in %fms' % ((time.clock() - loopStartTime) * 1000))

        loopStartTime = time.clock()
        for user in userTable:
            User = ScrumblesObjects.User(user)
            User.listOfAssignedItems = [
                I for I in self.items if I.itemUserID == User.userID
            ]
            User.listOfComments = [
                C for C in self.comments if C.commentUserID == User.userID
            ]
            self.users.append(User)
            self.userMap[User.userID] = User
        #print('User List Built in %fms' % ((time.clock() - loopStartTime) * 1000))

        loopStartTime = time.clock()
        for sprint in sprintTable:
            Sprint = ScrumblesObjects.Sprint(sprint)
            Sprint.listOfAssignedItems = [
                I for I in self.items if I.itemSprintID == Sprint.sprintID
            ]
            Sprint.listOfAssignedUsers = [
                U for U in self.users if U.userID in
                [I.itemUserID for I in Sprint.listOfAssignedItems]
            ]
            self.sprints.append(Sprint)
            self.sprintMap[Sprint.sprintID] = Sprint
        #print('Sprint List Built in %fms' % ((time.clock() - loopStartTime) * 1000))

        loopStartTime = time.clock()
        for project in projectTable:
            Project = ScrumblesObjects.Project(project)
            Project.listOfAssignedSprints = [
                S for S in self.sprints if S.projectID == Project.projectID
            ]
            self.projects.append(Project)
            self.projectMap[Project.projectID] = Project
        #print('Project List Built in %fms' % ((time.clock() - loopStartTime) * 1000))

        loopStartTime = time.clock()
        for user in self.users:
            for dict in userToProjectRelationTable:
                if dict['UserID'] == user.userID:
                    for project in self.projects:
                        if dict['ProjectID'] == project.projectID:
                            user.listOfProjects.append(project)
        #print('Users Spliced to Projects in %fms' % ((time.clock() - loopStartTime) * 1000))

        loopStartTime = time.clock()
        for project in self.projects:
            for dict in userToProjectRelationTable:
                if dict['ProjectID'] == project.projectID:
                    for user in self.users:
                        if dict['UserID'] == user.userID:
                            project.listOfAssignedUsers.append(user)
            #print('Projects spliced to users in %fms' % ((time.clock() - loopStartTime) * 1000))

            loopStartTime = time.clock()
            for dict in itemToProjectRelationTable:
                if dict['ProjectID'] == project.projectID:
                    for item in self.items:
                        if dict['ItemID'] == item.itemID:
                            item.projectID = project.projectID

                            project.listOfAssignedItems.append(item)
        #print('Items Spliced to Projects in %fms' % ((time.clock() - loopStartTime) * 1000))

        #self.debugDump()
        #print('Data Loaded in %fs' % (time.clock()-funcStartTime))
        self.isLoading = False
        return True