Пример #1
0
def f_gettask(taskid):
    data = pg.executequery2(
        'SELECT taskid,title,description,starttime,endtime,completiontime,status::text,priority::text,projectid,assignedby,array_agg(assignedto.username) AS assignedto,array_agg(preqtask.preqtask) AS preqtask FROM (task NATURAL JOIN assignedto) LEFT OUTER JOIN preqtask ON (assignedto.taskid = preqtask.task) WHERE taskid = %s GROUP BY taskid;',
        [taskid])
    x = data[0]
    return Task(x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9],
                x[10], x[11])
Пример #2
0
def f_myprojects(username, f):
    data = pg.executequery2('select * from myprojects(%s,%s)', [username, f])

    return [
        Project(x[0], x[1], x[2], x[3], x[4], x[5], x[6],
                [Member(i, j) for i, j in zip(x[7], x[8])]) for x in data
    ]
Пример #3
0
def f_getprojecttask(username, pid, task_filter):
    data = pg.executequery2("select * from project_task(%s,%s,%s)",
                            [username, pid, task_filter])

    return [
        Task(x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10],
             x[11]) for x in data
    ]
Пример #4
0
def f_getuser(username):
    data = pg.executequery2(
        'SELECT username,firstname,lastname,emailid FROM users WHERE username = %s',
        [username])
    if len(data) < 1:
        raise ValueError('User not found')
    else:
        return User(data[0][0], data[0][1], data[0][2], data[0][3])
Пример #5
0
def f_getproject(username, projectid):
    data = pg.executequery2("select * from getproject(%s,%s)",
                            [username, projectid])
    x = data[0]
    print(x)
    p = Project(x[0], x[1], x[2], x[3], x[4], x[5], x[6],
                [Member(i, j) for i, j in zip(x[7], x[8])])
    print(p)
    return p
Пример #6
0
def f_projectNotes(projectid):
    data = pg.executequery2(
        'select noteid,title,description,color,createdby,createdat from note where boardid = (select boardid from board where projectid = %s)',
        [projectid])
    return [Note(x[0], x[1], x[2], x[3], x[4], x[5]) for x in data]
Пример #7
0
def f_authenticate(username, password):
    data = pg.executequery2(
        'SELECT (password = crypt(%s, password)) AS pswmatch FROM users where username = %s ;',
        [password, username])
    return data[0][0]
Пример #8
0
def f_mynotes(username):
    data = pg.executequery2(
        'SELECT noteid,title,description,color,createdby,createdat from note WHERE boardid = (select boardid from board where username = %s)',
        [username])
    return [Note(x[0], x[1], x[2], x[3], x[4], x[5]) for x in data]
Пример #9
0
def f_getfiles(username, pid):
    data = pg.executequery2("select * from getfiles(%s,%s);", [username, pid])
    return [File(x[0], x[1], x[2], x[3], x[4]) for x in data]
Пример #10
0
def f_cum_analytics(pid, startdate, enddate):
    data = pg.executequery2(
        "select * from cumulative_daily_analytics(%s,%s::date,%s::date);",
        [pid, startdate, enddate])

    return [Analytics(x[0], x[1], x[2]) for x in data]
Пример #11
0
def f_getProjectReportUserwise(pid):
    data = pg.executequery2("select * from gen_userwise_report(%s)", [pid])
    return [
        UserReport(x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7])
        for x in data
    ]
Пример #12
0
def f_getProjectReport(pid):
    data = pg.executequery2("select * from gen_project_report(%s)", [pid])
    x = data[0]
    return Report(x[0], x[1], x[2], x[3], x[4], x[5], x[6])
Пример #13
0
def f_getUserReport(username):
    data = pg.executequery2("select * from gen_user_report(%s);", [username])
    x = data[0]
    return UserReport(username, x[0], x[1], x[2], x[3], x[4], x[5], x[6])