예제 #1
0
파일: data.py 프로젝트: etcwilde/linvis
def get_tree_data(cid):

    items = []
    with get_cursor() as cur:
        cur.execute(q_tree, {'cid': cid})
        items = [{
            "name": preview,
            "cid": mcid,
            "author": author,
            "mnext": mnext,
            "mlinus": mlinus,
            "children": None
        } for mcid, mnext, mlinus, preview, author, comdate, autdate in cur]

    tree_data = {}
    for item in items:
        tree_data[item['cid']] = item

    root = None
    for item in tree_data:
        if tree_data[item]['mnext']:
            if tree_data[tree_data[item]['mnext']]['children'] is None:
                tree_data[tree_data[item]['mnext']]['children'] = {}
            tree_data[tree_data[item]['mnext']]['children'][item] = \
                tree_data[item]
        else:
            root = tree_data[item]
    return json.dumps(root)
예제 #2
0
파일: data.py 프로젝트: etcwilde/linvis
def get_module(cid):
    items = []
    with get_cursor() as cur:
        cur.execute(q_moddata, {'cid': cid})
        items = [{
            "mname": get_mod_name(mname),
            "cid": mcid,
            "mnext": mnext,
            "mlinus": mlinus
        } for mcid, mnext, mlinus, mname in cur]
    tree_data = {}
    for item in items:
        tree_data[item['cid']] = {
            'cid': item['cid'],
            'mnext': item['mnext'],
            'children': [],
            'module': item['mname']
        }

    # Build tree
    for item in tree_data:
        if tree_data[item]['mnext']:
            if tree_data[tree_data[item]['mnext']]['children'] is None:
                tree_data[tree_data[item]['mnext']]['children'] =\
                    [tree_data[item]]
            else:
                tree_data[tree_data[item]['mnext']]['children']\
                    .append(tree_data[item])
    return json.dumps(tree_data[cid])
예제 #3
0
파일: data.py 프로젝트: etcwilde/linvis
def get_releases():
    with get_cursor() as cur:
        cur.execute(
            "SELECT ver, ver.autdate as \"End Date\", prevrealver, prev.autdate AS \"Start Date\" FROM releases JOIN (SELECT cid, autdate FROM commits) AS ver ON vercid=ver.cid JOIN (SELECT cid, autdate FROM commits) AS prev ON prevrealvercid=prev.cid WHERE not candidate ORDER BY ver;"
        )
        items = [{
            'ver': ver,
            'start': str(start.date()),
            'end': str(end.date())
        } for ver, end, _, start in cur]
        return json.dumps(items)
예제 #4
0
파일: data.py 프로젝트: etcwilde/linvis
def get_release(rel):
    items = []
    with get_cursor() as cur:
        cur.execute(
            "SELECT ver, ver.autdate as end, prevrealver, prev.autdate AS start FROM releases JOIN (SELECT cid, autdate FROM commits) AS ver ON vercid = ver.cid JOIN (SELECT cid, autdate FROM commits) AS prev on prevrealvercid = prev.cid WHERE ver = 'Linux 3.1';"
        )
        items = [{
            'ver': ver,
            'start': str(start.date()),
            'end': str(end.date())
        } for ver, end, _, start in cur]
        return json.dumps(items)
예제 #5
0
파일: data.py 프로젝트: etcwilde/linvis
def get_authors(cid):
    items = []
    with get_cursor() as cur:
        cur.execute(q_filedata, {'cid': cid})
        items = [{
            "fname": fname,
            "author": author,
            "added": added,
            "removed": removed,
            "cid": mcid
        } for mcid, mnext, mlinus, author, fname, added, removed in cur]
    return json.dumps([item for item in items if item['fname'] is not None])
예제 #6
0
파일: data.py 프로젝트: etcwilde/linvis
def get_commits():
    with get_cursor() as cur:
        cur.execute(
            "SELECT preview, cid, author ,comdate FROM logs NATURAL JOIN commits;"
        )
        items = [{
            "preview": preview,
            "cid": cid,
            "author": author,
            "comdate": str(comdate.date())
        } for preview, cid, author, comdate in cur]
        o = {"data": items[0:500]}
        return json.dumps(o)
예제 #7
0
파일: data.py 프로젝트: etcwilde/linvis
def get_files(cid):
    items = []
    with get_cursor() as cur:
        cur.execute(q_filedata, {'cid': cid})
        items = [{
            "fname": fname,
            "added": added,
            "removed": removed,
            "cid": mcid,
            "mnext": mnext,
            "mlinus": mlinus
        } for mcid, mnext, mlinus, _, fname, added, removed in cur]

    # Initialize Tree structure
    tree_data = {}
    for item in items:
        if item['cid'] in tree_data:
            tree_data[item['cid']]['files'].append(
                (item['fname'], item['added'], item['removed']))
        else:
            tree_data[item['cid']] = {
                "cid": item['cid'],
                "mnext": item['mnext'],
                "children": [],
                "files": [(item['fname'], item['added'], item['removed'])]
            }
    # Build tree
    for item in tree_data:
        if tree_data[item]['mnext']:
            if tree_data[tree_data[item]['mnext']]['children'] is None:
                tree_data[tree_data[item]['mnext']]['children'] =\
                    [tree_data[item]]
            else:
                tree_data[tree_data[item]['mnext']]['children']\
                    .append(tree_data[item])
    return json.dumps(tree_data[cid])
예제 #8
0
파일: searches.py 프로젝트: etcwilde/linvis
def get_breadcrumbs(cid):
    items = []
    with get_cursor() as cur:
        cur.execute(q_breadcrumb_tree, {'cid': cid})
        items = [{
            "cid": mcid,
            "mcidlinus": mcidlinus,
            "mnext": mnext
        } for mcid, mnext, mcidlinus in cur]
    tree_data = {}
    for item in items:
        tree_data[item['cid']] = item

    current_node = cid
    breadcrumbs = [cid]
    while current_node and current_node != "":
        try:
            current_node = tree_data[current_node]['mnext']
            if not current_node:
                break
            breadcrumbs.append(current_node)
        except KeyError:
            current_node = None
    return breadcrumbs[::-1]