def saveActiveProjectTaskMapping(worksheet: Worksheet, startRow: int = 1, startColumn: int = 1): """Saves the active project list and active task list data. The projects are stored in one row, the tasks corresponding to the project are saved in the same column as the project Arguments: worksheet {Worksheet} -- [description] startRow {int} -- starting row form where the data should be stored startColumn {int} -- starting column form where the data should be stored """ projectList = excelDatabase.getActiveProjects() if projectList is None: return for project in projectList: taskList = excelDatabase.getActiveTasksByProjectId(project.projectId) if taskList is None: taskList = [] task = Task() task.taskName = "-" taskList.append(task) project.taskList = taskList defaultProject = getDefaultProjects() projectList.extend(defaultProject) column = startColumn for project in projectList: row = startRow worksheet.cell(row=row, column=column).value = project.projectName for task in project.taskList: row += 1 worksheet.cell(row=row, column=column).value = task.taskName column += 1
def getDefaultProjects() -> list: """Creates default projects as defined in the configuration with default task "-". Returns: list -- List of Projects """ projectList = [] for projectName in DEFAULT_PROJECT: project = Project() project.projectName = projectName taskList = [] task = Task() task.taskName = "-" taskList.append(task) project.taskList = taskList projectList.append(project) return projectList
def getActiveTasksByProjectId(projectId: int) -> list: """Get active tasks by project ID Arguments: projectId {int} -- [description] """ cursor = connection.cursor() cursor.execute(SQLQueries.ACTIVE_TASK_BY_PROJECTNAME_GET, [projectId, "active"]) queryResult = cursor.fetchall() if (len(queryResult) == 0): return None taskList = [] for task in queryResult: taskData = Task() taskData.taskName = task[0] taskList.append(taskData) return taskList