Esempio n. 1
0
def edit_project(project_nr, new_name=None, new_description=None):
    pr = Project.find(project_nr)
    if new_name is not None:
        pr.name = new_name
    if new_description is not None:
        pr.description = new_description
    pr.save()
Esempio n. 2
0
def get_hours_per_project_for_employee(empl_nr: int):
    query = f"SELECT projectNr, SUM(TIMEDIFF(end_, start_)/10000) AS 'hours' " \
            f"FROM {entry.Entry.Table.name} " \
            f"WHERE emplNr={empl_nr} " \
            f"GROUP BY projectNr ORDER BY 'hours' DESC;"
    cur = db.get_conn().cursor()
    cur.execute(query)
    idx_emplnr = cur.column_names.index("projectNr")
    idx_hours = cur.column_names.index("hours")
    res = {
        Project.find(row[idx_emplnr]): row[idx_hours]
        for row in cur.fetchall()
    }
    cur.close()
    return res
Esempio n. 3
0
 def getProject(self) -> Project:
     if not self._project:
         self._project = Project.find(self._project_nr)
     return self._project