Пример #1
0
def periodValidation(startdate, enddate, channel):
    if startdate != None and enddate != None:
        strt = startdate.split("/")
        end = enddate.split("/")
        if len(end) == 3 and len(strt) == 3:
            strtyr = int(strt[0])
            strtmon = int(strt[1])
            strtdt = int(strt[2])
            endyr = int(end[0])
            endmon = int(end[1])
            endtdt = int(end[2])
            if strtyr < endyr:
                return True
            elif strtyr == endyr and strtmon < endmon:
                return True
            elif strtyr == endyr and strtmon == endmon and strtdt < endtdt:
                return True
            else:
                return False
        else:
            text = "Please check input again"
            SlackCommunication.postMessege(channel, text)
            return False

    else:
        text = "Please check input commands again"
        SlackCommunication.postMessege(channel, text)
Пример #2
0
def taskContent(dict):
    msg = dict.get("text")
    records = db.get_collection("task")
    manager = dict.get("user")
    channel = dict.get("channel")
    arraycontent = []
    array = msg.split(" ")
    if UserManager.checkUserRole(manager):
        taskid, content = None, None
        if array[0] == "-taskcontent" and array[1] == "-taskid" and array[
                3] == "-projectid":
            for x in range(5, len(array)):
                arraycontent.append(array[x])
                objectives = " ".join(arraycontent)
            if records.find_one_and_update(
                {
                    "taskid": array[2],
                    "projectid": array[4]
                }, {'$set': {
                    "taskcontent": objectives
                }}):
                text = "Data updated"
                SlackCommunication.postMessege(channel, text)
    else:
        text = "Only project manager can perform this command"
        SlackCommunication.postMessege(channel, text)
Пример #3
0
def checkAlltaskdetails(dicts):
    taskids, taskname, strtdate, enddate, totalslack, type, status, enddepends, strtsdepends = None, None, None, None, None, None, None, None, None
    documents = db.get_collection("task")
    channels = dicts.get("channel")
    manager = dicts.get("user")
    msg = dicts.get("text")
    if UserManager.checkUserRole(manager):
        count = 0
        array = msg.split(" ")
        for split in array:
            if split != None:
                if split[0] == "-":
                    if split == "-projectid":
                        projectid = array[count + 1]
                        taskids = documents.find({
                            "projectid": projectid
                        }).distinct("taskid")

            count = count + 1
        for taskid in taskids:
            taskname = documents.find({
                "taskid": taskid
            }).distinct("taskname")[0]
            strtdate = documents.find({
                "taskid": taskid
            }).distinct("starttime")[0]
            enddate = documents.find({"taskid": taskid}).distinct("endtime")[0]
            totalslack = documents.find({
                "taskid": taskid
            }).distinct("freeslack")[0]
            progress = documents.find({
                "taskid": taskid
            }).distinct("taskprogress")[0]
            type = documents.find({"taskid": taskid}).distinct("type")[0]
            status = documents.find({"taskid": taskid}).distinct("status")[0]
            enddepends = documents.find({
                "taskid": taskid
            }).distinct("enddepends")
            strtsdepends = documents.find({
                "taskid": taskid
            }).distinct("startdepends")
            if enddepends != None and enddepends != [] and enddepends != [
                    None
            ]:
                enddepends = enddepends[0]
            else:
                enddepends = "no depends"
            if strtsdepends != None and strtsdepends != [] and strtsdepends != [
                    None
            ]:
                strtsdepends = strtsdepends[0]
            else:
                strtsdepends = "no depends"
            text="\n Task name : "+taskname+" Task ID : "+taskid+"\n Start date : "+strtdate+\
                 " End date : "+enddate+" \n Task progress "+progress+" \n"+" Total Slack : "+totalslack+"\n Type : "+type+\
                 " Status : "+status+"\n  Depends : "+enddepends+" Start depends :" + strtsdepends
            SlackCommunication.postMessege(channels, text)
    else:
        text = "Only manager can perform this command"
        SlackCommunication.postMessege(channels, text)
Пример #4
0
def taskmongoupdate(channels, key, point, updates):
    record = None
    records = db.get_collection("task")
    record = records.find_one_and_update({"taskid": key},
                                         {'$set': {
                                             point: updates
                                         }})
    if record != None:
        text = "Data Updated"
        SlackCommunication.postMessege(channels, text)
Пример #5
0
def register_ProjectManager(dict):
    manager = dict.get("user")
    channel = dict.get("channel")
    records = db.get_collection("user")
    if records.find({"roleid": "2"}).count() == 0:
        record = records.find_one_and_update({"userid": manager},
                                             {'$set': {
                                                 "roleid": "2"
                                             }})
        text = "User <@" + manager + "> assinged to Manage this project"
        SlackCommunication.postMessege(channel, text)
    elif records.find({"userid": manager, "roleid": "2"}).count() == 1:
        text = "Only one can be a project manager"
        SlackCommunication.postMessege(channel, text)
Пример #6
0
def updateproject(dicts):
    channels = dicts.get("channel")
    msg = dicts.get("text")
    count = 0
    if UserManager.checkUserRole(dicts.get("user")):
        array = msg.split(" ")
        for split in array:
            if split != None:
                if split[0] == "-":
                    if split == "-projectid":
                        projectid = array[count + 1]
                    if split == "-projectname":
                        projectname = array[count + 1]
                        projectmongoupdate(channels, projectid, "projectname",
                                           projectname, dicts)
                    if split == "-totalslack":
                        totalslack = array[count + 1]
                        projectmongoupdate(channels, projectid, "totalslack",
                                           totalslack, dicts)
                    if split == "-startdate":
                        startdate = array[count + 1]
                        projectmongoupdate(channels, projectid, "startdate",
                                           startdate, dicts)
                    if split == "-enddate":
                        enddate = array[count + 1]
                        projectmongoupdate(channels, projectid, "enddate",
                                           enddate, dicts)
                    if split == "-managerid":
                        managerid = array[count + 1]
                        projectmongoupdate(channels, projectid, "managerid",
                                           managerid, dicts)
                    if split == "-githublink":
                        githublink = array[count + 1]
                        projectmongoupdate(channels, projectid, "githublink",
                                           githublink, dicts)

            count = count + 1
        text = "System updated!"
        SlackCommunication.postMessege(channels, text)

    else:
        text = "Only managers can perform this"
        SlackCommunication.postMessege(channels, text)
Пример #7
0
def deleteUser(dict):
    user = dict.get("user")
    count = 0
    userid = None
    channel = dict.get("channel")
    msg = dict.get("text")
    array = msg.split(" ")
    for split in array:
        if split == "-userid":
            userid = array[count + 1]
        count = count + 1
    records = db.get_collection("user")
    if userid != None and userid != "" and checkUserRole(user):
        userdetail = {"userid": userid}
        check = records.delete_one(userdetail).acknowledged
        if check:
            text = "<@" + user + "> Deleted."
            SlackCommunication.postMessege(channel, text)
        else:
            text = "Check input again."
            SlackCommunication.postMessege(channel, text)
Пример #8
0
def taskHold(dict):
    taskid, days, startdate, count = None, 0, None, 0
    msg = dict.get("text")
    manager = dict.get("user")
    channel = dict.get("channel")
    array = msg.split(" ")
    if UserManager.checkUserRole(manager):
        for split in array:
            if split != None and split != " ":
                if split[0] == "-":
                    if split == "-taskid":
                        taskid = array[count + 1]
                    if split == "-startdate":
                        startdate = array[count + 1]
                    if split == "-days":
                        days = int(array[count + 1])
            count = count + 1
        Task.taskforecast(taskid, startdate, days, channel)
    else:
        text = "Only project manager can perform this command"
        SlackCommunication.postMessege(channel, text)
Пример #9
0
def deleteTask(dict):
    user = dict.get("user")
    count = 0
    taskid = None
    channel = dict.get("channel")
    msg = dict.get("text")
    array = msg.split(" ")
    for split in array:
        if split == "-taskid":
            taskid = array[count + 1]
        count = count + 1
    records = db.get_collection("task")
    if taskid != None and taskid != "" and UserManager.checkUserRole(user):
        taskdetails = {"taskid": taskid}
        check = records.delete_one(taskdetails).acknowledged
        if check:
            text = taskid + " Task deleted."
            SlackCommunication.postMessege(channel, text)
        else:
            text = "Check input again."
            SlackCommunication.postMessege(channel, text)
Пример #10
0
def connectGithub(channels, managerid):
    documents = db.get_collection("project")
    paths = "../Projects/rep"
    if UserManager.checkUserRole(managerid):
        try:
            gitlink = documents.find({
                "managerid": managerid
            }).distinct("githublink")[0]
            if gitlink != None:
                if gitlink.split("//")[0] == "https:":
                    if os.path.exists(paths):
                        repo = Repo(paths)
                        repo.remotes.origin.pull()
                    else:
                        Repo.clone_from(gitlink, paths)
                    repo = Repo(paths)
                    if not repo.bare:
                        commits = list(repo.iter_commits('master'))[:10000]
                        for commit in commits:
                            checkcommit(channels, commit, repo)
                            pass
                    else:
                        text = 'Repo description: Server problem'
                        SlackCommunication.postMessege(channels, text)
            else:
                text = 'Link Github repository.'
                SlackCommunication.postMessege(channels, text)
        except:
            text = 'Complete github link registration first'
            SlackCommunication.postMessege(channels, text)
Пример #11
0
def checktaskdepend(dependset, channels):
    records = db.get_collection("task")
    if dependset != None and dependset != []:
        try:
            for item in dependset:
                check = records.find({
                    "taskid": item
                }, {
                    "taskid": 1
                }).distinct("taskid")[0]
                if check != None and check == item:
                    return True
                else:
                    text = "No task found,check depends again."
                    SlackCommunication.postMessege(channels, text)
                    return False
        except:
            text = "No task found,check depends again."
            SlackCommunication.postMessege(channels, text)
            return False
    else:
        return True
Пример #12
0
def enddependtask(channels, taskid, remaindays):
    documents = db.get_collection("task")
    taskprogress = documents.find({
        "taskid": taskid
    }).distinct("taskprogress")[0]
    taskfree = int(documents.find({"taskid": taskid}).distinct("freeslack")[0])
    starttime = documents.find({"taskid": taskid}).distinct("starttime")[0]
    endtime = documents.find({"taskid": taskid}).distinct("endtime")[0]
    type = documents.find({"taskid": taskid}).distinct("type")[0]
    status = documents.find({"taskid": taskid}).distinct("status")[0]
    endepends = documents.find({"taskid": taskid}).distinct("enddepends")
    startdepends = documents.find({"taskid": taskid}).distinct("startdepends")

    if remaindays != None and remaindays > 0:
        remaindays = remaindays - taskfree
        if remaindays < 0:
            remaindays = 0
        if endepends != None and endepends != []:
            endepends = endepends[0]
        if startdepends != None and startdepends != []:
            startdepends = startdepends[0]
        dicarray = {
            "taskids": taskid,
            "taskprogress": taskprogress,
            "type": type,
            "taskfree": taskfree,
            "starttime": starttime,
            "endtime": endtime,
            "status": status,
            "endepends": endepends,
            "startdepends": startdepends,
            "remaindays": remaindays,
        }
        arrays.append(dicarray)
        subTaskcheck(arrays, remaindays, 2, channels)
    else:
        text = "Task can hold till requested days."
        SlackCommunication.postMessege(channels, text)
Пример #13
0
def register_Project(dict):
    count = 0
    user = dict.get("user")
    msg = dict.get("text")
    channels = dict.get("channel")
    if UserManager.checkUserRole(user):
        projectid, projectname, startdate, enddate, totalslack = None, None, None, None, None
        array = msg.split(" ")
        for split in array:
            if split[0] != None and split[0] != " ":
                if split[0] == "-":
                    if split == "-projectid":
                        projectid = array[count + 1]
                    if split == "-projectname":
                        projectname = array[count + 1]
                    if split == "-startdate":
                        startdate = array[count + 1]
                    if split == "-enddate":
                        enddate = array[count + 1]
                    if split == "-totalslack":
                        totalslack = array[count + 1]
            count = count + 1
        records = db.get_collection("project")
        if periodValidation(
                startdate, enddate, channels
        ) and projectid != None and projectname != None and startdate != None and enddate != None and totalslack != None and Task.duplicateChecker(
                "projectid", projectid, "project"):
            mydict = {
                "projectid": projectid,
                "projectname": projectname,
                "startdate": startdate,
                "enddate": enddate,
                "totalslack": totalslack,
                "managerid": user
            }
            ischecked = records.insert_one(mydict).acknowledged
            if ischecked:
                text = "Project  " + projectname + " is connected"
                SlackCommunication.postMessege(channels, text)
            else:
                text = "Process terminated. Try again"
                SlackCommunication.postMessege(channels, text)
        else:
            text = "Check input again"
            SlackCommunication.postMessege(channels, text)
    else:
        text = "Only project manager can perform this project"
        SlackCommunication.postMessege(channels, text)
Пример #14
0
def workassigner(dict):
    id, userid = None, None
    count = 0
    taskids = ""
    taskvalidate, isvalidate = False, True
    user = dict.get("user")
    records = db.get_collection("user")
    channel = dict.get("channel")
    msg = dict.get("text")
    array = msg.split(" ")
    for split in array:
        if split != None:
            if split == "-userid":
                userid = array[count + 1]
            if split == "-tasksid":
                for countnumber in range(count + 1, len(array)):
                    taskids = taskids + " " + str(array[countnumber])
        count = count + 1

    if taskids != "":
        checktaskid = taskids.split(" ")
        for checks in checktaskid:
            if checks != "" and checks != " " and checks != None:
                isvalidtask = Task.rightTask(checks)
                if isvalidtask == False:
                    isvalidate = False
                    break
        if isvalidate and checkUserRole(user):
            if records.find_one_and_update(
                {"userid": userid}, {'$set': {
                    "allocatedtasks": taskids
                }}):
                text = "<@" + user + "> asssigned to do " + taskids + "."
                SlackCommunication.postMessege(channel, text)
        else:
            text = "Assigning failed"
            SlackCommunication.postMessege(channel, text)
Пример #15
0
def projectmongoupdate(channels, key, point, updates, dicts):
    records = db.get_collection("project")
    if UserManager.checkUserRole(dicts.get("user")):
        record = records.find_one_and_update({"projectid": key},
                                             {'$set': {
                                                 point: updates
                                             }})
        if record != None:
            text = "Data Updated"
            channel = channels
            SlackCommunication.postMessege(channel, text)
        else:
            text = "Data Updates fail"
            channel = channels
            SlackCommunication.postMessege(channel, text)
    else:
        text = "You don't have permission"
        channel = channels
        SlackCommunication.postMessege(channel, text)
Пример #16
0
def update_github(dict):
    count = 0
    msg = dict.get("text")
    manager = dict.get("user")
    channel = dict.get("channel")
    ts = dict.get("ts")
    githublink = None
    array = msg.split(" ")
    if UserManager.checkUserRole(manager):
        for split in array:
            try:
                if split != None and split != "":
                    if split[0] == "-":
                        if split == "-githublink":
                            githublink = array[count + 1]
            except:
                break
            count = count + 1
        SlackCommunication.deleteMessege(channel, ts)
        records = db.get_collection("project")
        if githublink == "" or githublink == None:
            text = "User command is incomplete. Please input right command to proceed"
            SlackCommunication.postMessege(channel, text)
        else:
            if UserManager.checkUserRole(manager) and githublink != None:
                githublink = githublink[1:]
                githublink = githublink[:-1]
                githublink = githublink.split("|")[0]
                if records.find_one_and_update(
                    {"managerid": manager},
                    {'$set': {
                        "githublink": githublink
                    }}):
                    text = "Github linked"
                    SlackCommunication.postMessege(channel, text)
    else:
        text = "Only manager can performe this command and need to configure at the beginning of project"
        SlackCommunication.postMessege(channel, text)
Пример #17
0
def create_Task(dict):
    manager = dict.get("user")
    channel = dict.get("channel")
    count = 0
    if UserManager.checkUserRole(manager):
        taskname = None
        taskid = None
        projectid = None
        starttime = None
        endtime = None
        type = None
        taskcontent = None
        msg = dict.get("text")
        array = msg.split(" ")

        for split in array:
            if split != None and split != " ":
                if split[0] == "-":
                    if split == "-taskname":
                        taskname = array[count + 1]
                    if split == "-taskid":
                        taskid = array[count + 1]
                    if split == "-projectid":
                        projectid = array[count + 1]
                    if split == "-freeslack":
                        freeslack = array[count + 1]
                    if split == "-startdate":
                        starttime = array[count + 1]
                    if split == "-enddate":
                        endtime = array[count + 1]
                    if split == "-taskcontent":
                        taskcontent = array[count + 1]
                    if split == "-type":
                        if array[count + 1] == "important" or array[
                                count +
                                1] == "normal" or array[count +
                                                        1] == "critical":
                            type = array[count + 1]
            count = count + 1
        if dateValidation(
                manager, projectid, starttime, endtime) and periodValidation(
                    starttime, endtime, channel) and Task.duplicateChecker(
                        "taskid", taskid, "task"):
            records = db.get_collection("task")
            mydict = {
                "taskname": taskname,
                "taskid": taskid,
                "projectid": projectid,
                "taskprogress": "0",
                "freeslack": freeslack,
                "starttime": starttime,
                "endtime": endtime,
                "type": type,
                "status": "fine",
                "taskcontent": taskcontent
            }
            ischeck = records.insert_one(mydict).acknowledged
            if ischeck:
                text = "Task created"
                SlackCommunication.postMessege(channel, text)
        else:
            text = "Process terminated. Check input again"
            SlackCommunication.postMessege(channel, text)
    else:
        text = "Only project manager can perform this project"
        SlackCommunication.postMessege(channel, text)
Пример #18
0
def informationsender(remaindays, taskfree, taskid, channels, status, type):
    if remaindays > taskfree:
        if status == "critical":
            text = "task " + taskid + " is  in critical stage. So its risk to hold task for " + str(
                remaindays) + " days."
            SlackCommunication.postMessege(channels, text)
        elif status != "fine" and status != "finished":
            text = "task " + taskid + " is in not good stage. So its risk to hold task for " + str(
                remaindays) + " days."
            SlackCommunication.postMessege(channels, text)
            if type == "important":
                text = "Also task " + taskid + " is important tasks "
                SlackCommunication.postMessege(channels, text)
        else:
            text = "Task status is" + status
            SlackCommunication.postMessege(channels, text)
            if remaindays > 0:
                text = "But holding more than free slack is risk"
                SlackCommunication.postMessege(channels, text)
    else:
        text = "task " + taskid + " can hold " + str(remaindays) + " days."
        SlackCommunication.postMessege(channels, text)
Пример #19
0
def blockedTasks(taskid, holdstrtyr, holdstrtmon, holdstrtdt, holdendyr,
                 holdendmonth, holdenddate, taskstrtyr, taskstrtmon,
                 taskstrtdt, taskendyr, taskendmon, taskenddt, channels, days,
                 remaindays):
    #############################################################################
    if taskstrtyr == holdstrtyr and taskstrtmon == holdstrtmon and taskstrtdt == holdstrtdt:
        startdependtask(channels, taskid, remaindays)
    elif taskendyr == holdendyr and taskendmon == holdendmonth and taskenddt == holdenddate:
        enddependtask(channels, taskid, remaindays)
    #############################################################################
    elif taskstrtyr > holdstrtyr and taskendyr < holdendyr:
        enddependtask(channels, taskid, remaindays)
        startdependtask(channels, taskid, remaindays)
    elif taskstrtyr < holdstrtyr and taskendyr < holdendyr:
        enddependtask(channels, taskid, remaindays)
    elif taskstrtyr > holdstrtyr and taskendyr > holdendyr:
        startdependtask(channels, taskid, remaindays)
    ############################################################################
    elif taskstrtyr == holdstrtyr and taskendyr < holdendyr:
        enddependtask(channels, taskid, remaindays)
        if taskstrtmon > holdstrtmon:
            startdependtask(channels, taskid, remaindays)
        if taskstrtmon == holdstrtmon:
            if taskstrtdt > holdstrtdt or taskstrtdt == holdstrtdt:
                startdependtask(channels, taskid, remaindays)
    elif taskstrtyr == holdstrtyr and taskendyr > holdendyr:
        if taskstrtmon > holdstrtmon:
            startdependtask(channels, taskid, remaindays)
        if taskstrtmon == holdstrtmon:
            if taskstrtdt > holdstrtdt or taskstrtdt == holdstrtdt:
                startdependtask(channels, taskid, remaindays)
    elif taskstrtyr > holdstrtyr and taskendyr == holdendyr:
        startdependtask(channels, taskid, remaindays)
        if taskendmon < holdendmonth:
            enddependtask(channels, taskid, remaindays)
        if taskendmon == holdendmonth:
            if taskenddt < holdenddate or taskenddt == holdenddate:
                enddependtask(channels, taskid, remaindays)
    elif taskstrtyr < holdstrtyr and taskendyr == holdendyr:
        if taskendmon < holdendmonth:
            enddependtask(channels, taskid, remaindays)
        if taskendmon == holdendmonth:
            if taskenddt < holdenddate or taskenddt == holdenddate:
                enddependtask(channels, taskid, remaindays)
    #############################################################################
    elif taskstrtyr == holdstrtyr and taskendyr == holdendyr:
        if taskstrtmon < holdstrtmon and taskendmon < holdendmonth:
            enddependtask(channels, taskid, remaindays)
        elif taskstrtmon == holdstrtmon and taskendmon < holdendmonth:
            enddependtask(channels, taskid, remaindays)
            if taskstrtdt > holdstrtdt or taskstrtdt == holdstrtdt:
                startdependtask(channels, taskid, remaindays)
        elif taskstrtmon == holdstrtmon and taskendmon > holdendmonth:
            if taskstrtdt > holdstrtdt or taskstrtdt == holdstrtdt:
                startdependtask(channels, taskid, remaindays)

        elif taskstrtmon < holdstrtmon and taskendmon == holdendmonth:
            if taskenddt < holdenddate or taskenddt == holdenddate:
                enddependtask(channels, taskid, remaindays)
        elif taskstrtmon == holdstrtmon and taskendmon == holdendmonth:
            if taskstrtdt < holdstrtdt and taskenddt < holdenddate:
                enddependtask(channels, taskid, remaindays)
            elif taskstrtdt == holdstrtdt and taskenddt < holdenddate:
                startdependtask(channels, taskid, remaindays)
                enddependtask(channels, taskid, remaindays)
            elif taskstrtdt == holdstrtdt and taskenddt > holdenddate:
                startdependtask(channels, taskid, remaindays)
            elif taskstrtdt < holdstrtdt and taskenddt > holdenddate:
                if remaindays != 0:
                    enddependtask(channels, taskid, remaindays)
            elif taskstrtdt < holdstrtdt and taskenddt == holdenddate:
                enddependtask(channels, taskid, remaindays)
            elif taskstrtdt > holdstrtdt and taskenddt == holdenddate:
                startdependtask(channels, taskid, remaindays)
                enddependtask(channels, taskid, remaindays)
            elif taskstrtdt == holdstrtdt and taskenddt == holdenddate:
                startdependtask(channels, taskid, remaindays)
                enddependtask(channels, taskid, remaindays)
        else:
            text = "Please check your input again"
            SlackCommunication.postMessege(channels, text)
    else:
        text = "Please check your input again"
        SlackCommunication.postMessege(channels, text)
Пример #20
0
def settaskdepends(dict):
    count = 0
    msg = dict.get("text")
    channels = dict.get("channel")
    user = dict.get("user")
    if UserManager.checkUserRole(user):
        main, startdepends, enddepends = None, None, None
        array = msg.split(" ")
        for split in array:
            if split != None and split != "":
                if split[0] == "-":
                    if split == "-maintask":
                        main = array[count + 1]
                    if split == "-startdepends":
                        startdepends = array[count + 1]
                    if split == "-endepends":
                        enddepends = array[count + 1]
            count = count + 1
        records = db.get_collection("task")
        startdep = records.find({
            "taskid": main
        }, {
            "taskid": 1
        }).distinct("startdepends")
        enddep = records.find({
            "taskid": main
        }, {
            "taskid": 1
        }).distinct("enddepends")

        if listCheck(startdepends, startdep) and listCheck(enddepends, enddep):

            if startdep != None and startdep != [] and startdep != [
                    None
            ] and startdepends != None:
                startdepends = startdepends + "," + str(startdep[0])
            elif startdep != None and startdep != [] and startdep != [
                    None
            ] and startdepends == None:
                startdepends = str(startdep[0])

            if enddep != None and enddep != [] and enddep != [
                    None
            ] and enddepends != None:
                enddepends = enddepends + "," + str(enddep[0])
            elif enddep != None and enddep != [] and enddep != [
                    None
            ] and enddepends == None:
                enddepends = str(enddep[0])

            startlen, endlen = 0, 0
            if main != None:
                if startdepends != None and startdepends != []:
                    startdependset = startdepends.split(",")
                    startlen = len(startdependset)
                else:
                    startdependset = None
                if enddepends != None and enddepends != []:
                    enddependset = enddepends.split(",")
                    endlen = len(enddependset)
                else:
                    enddependset = None
                if checktaskdepend(startdependset,
                                   channels) and checktaskdepend(
                                       enddependset, channels):
                    countdepend = startlen + endlen
                    record = records.find_one_and_update({"taskid": main}, {
                        '$set': {
                            "startdepends": startdepends,
                            "enddepends": enddepends
                        }
                    })
                    if record:
                        text = str(
                            countdepend) + " tasks depend on " + main + " task"
                        SlackCommunication.postMessege(channels, text)
                    else:
                        text = "Process terminated. Check input again"
                        SlackCommunication.postMessege(channels, text)
        else:
            text = "Some depends already submitted"
            SlackCommunication.postMessege(channels, text)
    else:
        text = "Only project manager can perform this project"
        SlackCommunication.postMessege(channels, text)
Пример #21
0
def taskforecast(taskid, startdate, days, channels):
    try:
        global start
        start = 0
        arrays.clear()
        holdendyr, holdendmonth, holdenddate, remaindays = 0, 0, 0, 0
        documents = db.get_collection("task")
        taskfree = int(
            documents.find({
                "taskid": taskid
            }).distinct("freeslack")[0])
        starttime = documents.find({"taskid": taskid}).distinct("starttime")[0]
        endtime = documents.find({"taskid": taskid}).distinct("endtime")[0]
        if (days > taskfree):
            remaindays = days - taskfree

        holdtarttime = startdate.split("/")
        holdstrtyr = int(holdtarttime[0])
        holdstrtmon = int(holdtarttime[1])
        holdstrtdt = int(holdtarttime[2])

        taskstarttime = starttime.split("/")
        taskstrtyr = int(taskstarttime[0])
        taskstrtmon = int(taskstarttime[1])
        taskstrtdt = int(taskstarttime[2])

        taskendtime = endtime.split("/")
        taskendyr = int(taskendtime[0])
        taskendmon = int(taskendtime[1])
        taskenddt = int(taskendtime[2])
        holdendyr = holdstrtyr
        holdendmonth = holdstrtmon
        holdenddate = holdstrtdt
        if (holdstrtdt + days) > 30 and days < 30:
            holdenddate = days - (30 - holdstrtdt)
            if ((holdstrtmon + 1) < 12):
                holdendmonth = holdstrtmon + 1
            else:
                holdendyr = holdstrtyr + 1
                holdendmonth = 1
        elif (holdstrtdt + days) < 30:
            holdenddate = holdstrtdt + days
        elif (holdstrtdt + days) > 30 and days > 30:
            months = math.floor(days / 30)
            xdays = days - months * 30
            if months > 12:
                years = math.floor(months / 12)
                xmonths = months - years * 12
                holdendyr = holdstrtyr + years
                holdendmonth = holdstrtmon + xmonths
                holdenddate = holdstrtdt + xdays
                if holdendmonth > 12:
                    holdendyr = holdendyr + 1
                    holdendmonth = xmonths - (12 - holdstrtmon)
                if holdenddate > 30:
                    holdendmonth = holdendmonth + 1
                    holdenddate = xdays - (30 - holdstrtdt)

        blockedTasks(taskid, holdstrtyr, holdstrtmon, holdstrtdt, holdendyr,
                     holdendmonth, holdenddate, taskstrtyr, taskstrtmon,
                     taskstrtdt, taskendyr, taskendmon, taskenddt, channels,
                     days, remaindays)

    except:
        text = "System crashed."
        SlackCommunication.postMessege(channels, text)
Пример #22
0
def checkcommit(channels, commit, repo):
    count, istest = 0, 0
    commitcontent = ""
    check = 0
    projectid, taskid, taskname = None, None, None
    taskcontentarray, checkedcommits = None, None
    commitarray = commit.message
    commitarray = TextBlob(commitarray)
    commitarray = commitarray.words
    documents = db.get_collection("task")
    projectdocuments = db.get_collection("project")
    if len(commitarray) > 3:
        for word in commitarray:
            if word != None:
                if word == "projectid":
                    projectid = commitarray[count + 1]
                if word == "taskid":
                    taskid = commitarray[count + 1]
                if word == "taskname":
                    taskname = commitarray[count + 1]
            count = count + 1
        if projectid != [] and projectid != None:
            checkedcommits = projectdocuments.find({
                "projectid": projectid
            }).distinct("checkedcommits")
            for checkedcommit in checkedcommits:
                if str(commit.hexsha) == checkedcommit:
                    check = 1
                    break

        if projectid != None and taskid != None and taskname != None:
            taskcontentarray = documents.find({
                "taskname": taskname,
                "taskid": taskid,
                "projectid": projectid
            }).distinct("taskcontent")
            if taskcontentarray != [] and taskcontentarray != None:
                taskcontentarray = taskcontentarray[0].split("#")

        else:
            text = "Skip one commit message : Not according to structure"
            SlackCommunication.postMessege(channels, text)
        if check == 0:

            commitscontent = None
            completedsubtasks, counts = 0, 0
            count, istest = 0, 0
            if taskcontentarray != [] and taskcontentarray != None:
                for y in range(7, len(commitarray)):
                    if commitarray[y] != None and commitarray[
                            y] != " " and commitarray[y] != "":
                        commitcontent = commitcontent + " " + commitarray[y]
                numberarray = re.findall(r'\b\d+\b', commitcontent)
                if len(numberarray) == 1:
                    splt = str(numberarray[count]) + "."
                    commitscontent = commitcontent.split(splt)
                for num in range(0, len(numberarray) - 1):
                    splt = str(numberarray[count]) + "."
                    spltl = str(numberarray[count + 1]) + "."
                    contentfilter = commitcontent.split(splt)
                    commitscontent = contentfilter[1].split(spltl)
                    count = count + 1
                if commitscontent != None:
                    for rep in taskcontentarray:
                        if rep != '':
                            counts = counts + 1
                            for turns in commitscontent:
                                if turns != '':
                                    ratio = fuzz.ratio(str(turns), str(rep))
                                    if ratio > 85:
                                        completedsubtasks = completedsubtasks + 1
                                    elif TextBlob(turns).words.count(
                                            'Completed') > 0 and ratio > 59:
                                        completedsubtasks = completedsubtasks + 1
                                    elif TextBlob(turns).words.count(
                                            'Finished') > 0 and ratio > 59:
                                        completedsubtasks = completedsubtasks + 1

                                    if TextBlob(turns).words.count(
                                            'tested') > 1 or TextBlob(
                                                turns).words.count(
                                                    'verified') > 1:
                                        istest = 10

                if completedsubtasks > 0 and counts > 0:
                    commitcompletion = (
                        (completedsubtasks / counts) * 100) - 10 + istest
                    documents.find_one_and_update(
                        {"taskid": taskid},
                        {'$set': {
                            "taskprogress": str(commitcompletion)
                        }})
                    if (commitcompletion == 100):
                        documents.find_one_and_update(
                            {"taskid": taskid},
                            {'$set': {
                                "status": "finished"
                            }})
                    if (commitcompletion > 85):
                        documents.find_one_and_update(
                            {"taskid": taskid}, {'$set': {
                                "status": "fine"
                            }})
                    elif (commitcompletion > 50 and commitcompletion < 85):
                        documents.find_one_and_update(
                            {"taskid": taskid},
                            {'$set': {
                                "status": "working"
                            }})
                    elif (commitcompletion < 50):
                        documents.find_one_and_update(
                            {"taskid": taskid},
                            {'$set': {
                                "status": "critical"
                            }})
                text = "Checked commit message and update project progress."
                SlackCommunication.postMessege(channels, text)
        if check == 0:
            projectdocuments.update(
                {"projectid": projectid},
                {'$push': {
                    "checkedcommits": str(commit.hexsha)
                }})
Пример #23
0
def registration(dict):
    user = dict.get("user")
    channel = dict.get("channel")
    count = 0
    location, email, fullname = None, None, None
    msg = dict.get("text")
    array = msg.split(" ")
    for split in array:
        if split != None:
            if split[0] == "-":
                if split == "-location":
                    location = array[count + 1]
                if split == "-email":
                    email = array[count + 1]
                    try:
                        email = email.split("|")[1]
                        email = email[:-1]
                    except:
                        email = ""
                        text = "Please check email domain"
                        SlackCommunication.postMessege(channel, text)
                if split == "-fullname":
                    fullname = array[count + 1]
        count = count + 1
    records = db.get_collection("user")
    if user != None and fullname != None and email != None and location != None:
        if rightEmail(email):
            if Task.duplicateChecker("userid", user, "user"):
                mydict = {
                    "userid": user,
                    "fullname": fullname,
                    "email": email,
                    "location": location
                }
                ischecked = records.insert_one(mydict).acknowledged
                if ischecked:
                    text = "<@" + user + "> registered to system."
                    SlackCommunication.postMessege(channel, text)
                else:
                    text = "Registration failed."
                    SlackCommunication.postMessege(channel, text)
            else:
                text = "Alreqady registered."
                SlackCommunication.postMessege(channel, text)
        else:
            text = "Please check email again."
            SlackCommunication.postMessege(channel, text)
    else:
        text = "You should set input parameters with values."
        SlackCommunication.postMessege(channel, text)
Пример #24
0
def statusUpdater(dict):
    text = None
    projectdocuments = db.get_collection("project")
    taskdocument = db.get_collection("task")
    managerid = dict.get("user")
    channels = dict.get("channel")
    projectids = projectdocuments.find({
        "managerid": managerid
    }, {
        "roleid": "2"
    }).distinct("projectid")
    if projectids != [] and projectids != None:
        projectids = projectids[0]
        taskdetailarray = taskdocument.find({
            "projectid": projectids
        }).distinct("taskid")
        if taskdetailarray != []:
            for taskids in taskdetailarray:
                tasktime = taskdocument.find({
                    "taskid": taskids
                }).distinct("endtime")[0]
                taskstarttime = taskdocument.find({
                    "taskid": taskids
                }).distinct("starttime")[0]
                nows = str(datetime.datetime.now().date())
                checkdate = nows.replace("-", "/", 2)
                currentremain = Task.periodCalculator(checkdate, tasktime)
                tasktimes = Task.periodCalculator(taskstarttime, tasktime)
                ratio = currentremain / tasktimes
                taskprogress = int(
                    float(
                        taskdocument.find({
                            "taskid": taskids
                        }).distinct("taskprogress")[0]))
                tasktype = taskdocument.find({
                    "taskid": taskids
                }).distinct("type")[0]
                if (taskprogress > 90 and taskprogress < 100):
                    if ratio < 1 and ratio > 0.5:
                        if tasktype == "critical" or tasktype == "important":
                            text = taskids + "is almost done but keep work on. " + tasktype + " task"
                    elif ratio < 0.5:
                        if tasktype == "critical" or tasktype == "important":
                            text = taskids + "is almost done but keep work on. " + tasktype + " task"
                            taskdocument.find_one_and_update(
                                {"taskid": taskids},
                                {'$set': {
                                    "status": "working"
                                }})

                elif (taskprogress > 50 and taskprogress < 90):
                    if ratio < 1 and ratio > 0.5:
                        if tasktype == "critical" or tasktype == "important":
                            text = taskids + "need full attention because " + tasktype + " task"

                    elif ratio < 0.5:
                        if tasktype == "critical" or tasktype == "important":
                            text = taskids + "need full attention because " + tasktype + " task"
                            taskdocument.find_one_and_update(
                                {"taskid": taskids},
                                {'$set': {
                                    "status": "critical"
                                }})
                elif (taskprogress < 50):
                    if ratio < 1 and ratio > 0.5:
                        if tasktype == "critical" or tasktype == "important":
                            text = taskids + "is almost done but keep work on. " + tasktype + " task"
                            taskdocument.find_one_and_update(
                                {"taskid": taskids},
                                {'$set': {
                                    "status": "working"
                                }})
                    elif ratio < 0.5:
                        text = taskids + "is in reallly bad stage. its " + tasktype + " task"
                        taskdocument.find_one_and_update(
                            {"taskid": taskids},
                            {'$set': {
                                "status": "critical"
                            }})

                SlackCommunication.postMessege(channels, text)