Ejemplo n.º 1
0
def juxta_basicstats(u):
    ns = u.note_owner
    nvals = u.note_owner.values()
    stats = (
        ("N", ns.count()),  ## number of notes
        ("keep/del", "%s/%s" % (ns.filter(deleted=0).count(), ns.filter(deleted=1).count())),
        ("s:", exporter.makedate_usec(min([float(x["created"]) for x in nvals]))),
        ("l:", exporter.makedate_usec(max([float(x["edited"]) for x in nvals] + [float(x["created"]) for x in nvals]))),
        ("|words|", mean([ca.note_words(nvs)[1] for nvs in nvals])),
        ("|chars|", mean([len(nvs["contents"].strip()) for nvs in nvals])),
        ("|urls%|", sum([1 for nvs in nvals if ca.note_urls(nvs)[1] > 0]) / (1.0 * ns.count()) * 100),
        ("|#vers|", mean([float(nvs["version"]) for nvs in nvals])),
    )
    return '<span class="userstats">%s</span>' % "; ".join(
        ['%s: <span class="val">%s</span>' % (k, v) for k, v in stats]
    )
Ejemplo n.º 2
0
def juxta_basicstats(u):
    ns = u.note_owner
    nvals = u.note_owner.values()
    stats = (
        ("N", ns.count()),  ## number of notes
        ("keep/del", "%s/%s" %
         (ns.filter(deleted=0).count(), ns.filter(deleted=1).count())),
        ("s:", exporter.makedate_usec(min([float(x['created'])
                                           for x in nvals]))),
        ("l:",
         exporter.makedate_usec(
             max([float(x['edited'])
                  for x in nvals] + [float(x['created']) for x in nvals]))),
        ("|words|", mean([ca.note_words(nvs)[1] for nvs in nvals])),
        ("|chars|", mean([len(nvs['contents'].strip()) for nvs in nvals])),
        ("|urls%|", sum([1 for nvs in nvals if ca.note_urls(nvs)[1] > 0]) /
         (1.0 * ns.count()) * 100),
        ("|#vers|", mean([float(nvs['version']) for nvs in nvals])))
    return '<span class="userstats">%s</span>' % "; ".join(
        ['%s: <span class="val">%s</span>' % (k, v) for k, v in stats])
Ejemplo n.º 3
0
        for jid, when in vs:
            if not (jid in max_deletes) or max_deletes[jid] < float(when):
                max_deletes[jid] = float(when)

        njidtodel[n.owner.email] = dict([
            (jid, (when - float(n.created)))
            for jid, when in max_deletes.iteritems()
        ])
    return njidtodel[n.owner.email].get(n.jid, None)


juxtapose_n_props = lambda i, n_created, n_text, n: "".join([
    ("<td>%s</td>" % repr(x)) for x in [
        i,
        int(n.jid),
        exporter.makedate_usec(float(n_created)),
        (time_till_deletion(n) / (24 * 60 * 60 * 1000)
         if time_till_deletion(n) is not None else "-?-")
        if n.deleted else "NOT DELETED",
        len(n_text) if n_text is not None else 0,
        ca.note_words(text2vals(n_text))[1] if n_text is not None else 0,
        ca.note_lines(text2vals(n_text))[1] if n_text is not None else 0,
        ca.note_changed_edits(n2vals(n))[1],
        htmlesc(n_text)
    ]
])

njidtosave = {}


def juxtapose_note(i, n):
Ejemplo n.º 4
0
        max_deletes = {}
        for jid, when in vs:
            if not (jid in max_deletes) or max_deletes[jid] < float(when):
                max_deletes[jid] = float(when)

        njidtodel[n.owner.email] = dict([(jid, (when - float(n.created))) for jid, when in max_deletes.iteritems()])
    return njidtodel[n.owner.email].get(n.jid, None)


juxtapose_n_props = lambda i, n_created, n_text, n: "".join(
    [
        ("<td>%s</td>" % repr(x))
        for x in [
            i,
            int(n.jid),
            exporter.makedate_usec(float(n_created)),
            (time_till_deletion(n) / (24 * 60 * 60 * 1000) if time_till_deletion(n) is not None else "-?-")
            if n.deleted
            else "NOT DELETED",
            len(n_text) if n_text is not None else 0,
            ca.note_words(text2vals(n_text))[1] if n_text is not None else 0,
            ca.note_lines(text2vals(n_text))[1] if n_text is not None else 0,
            ca.note_changed_edits(n2vals(n))[1],
            htmlesc(n_text),
        ]
    ]
)

njidtosave = {}