Roundup Tracker - Issues


Author tekberg
Recipients rouilj, tekberg
Date 2019-01-08.19:50:21
Message-id <>
I have been working on an oncall tracker where is it useful for the
nosy email to show specific fields (problem description, page
date/time, call-back phone, etc.) even when they don't change. This
issue describes a modification to the roundup code that allows nosy
wmail to generate a custom body.

The modification involves passing a function as an optional parameter,
calling the function, if non-None, after the email body gets
built. The email body becomes whatever the function returns. The
function can return the original body or replace it with something

The change is to the nosymessage function in roundup/ The
new note_filter parameter to nosymessage defaults to None. If
note_filter is specified it is assumed to be a function with this

            note_filter(original_note, issueid, newvalues, oldvalues)

If called, the note_filter function returns the new value for the
message body.

Example use:

Make a custom change to detectors/ In the nosyreaction
function change this line:

            cl.nosymessage(nodeid, msgid, oldvalues)

to something like this:

            cl.nosymessage(nodeid, msgid, oldvalues, 

Where format_oncall_message is a new function like this:

def format_oncall_message(original_note, issue_id, newvalues, 
    Format the message like the lmit_oncall tracker did with nice 
field names.

    Determine if the description changed or if there are new 
    and return detail that should go into the body of the email 

    email_details = []
    new_description = newvalues.get(issue_id, 'description')
    # If this is a new issue and it has a description, or if the issue
    # was edited and the description changed.
    have_new_description = ((oldvalues is None and new_description) or
                            (oldvalues is not None and
                             'description' in oldvalues and
                             (oldvalues.get('description') != 
    new_messages = determineNewMessages(newvalues, issue_id, 

    # Have new detail. Add the common detail first.
    if have_new_description or new_messages:
        if newvalues.get(issue_id, 'pagedate'):
            email_details.append('Page Date: %s' % 
(newvalues.get(issue_id, 'pagedate').pretty(format='%Y-%m-%d'),))
        if newvalues.get(issue_id, 'pagetime'):
            email_details.append('Page Time: %s' % 
(newvalues.get(issue_id, 'pagetime'),))
        email_details.append('Name: %s' % (newvalues.get(issue_id, 
        source_id = newvalues.get(issue_id, 'source')
        if source_id:
            email_details.append('Source: %s' % 
(db.source.get(source_id, 'name'),))
        location_id = newvalues.get(issue_id, 'location')
        if location_id:
            email_details.append('Location: %s' % 
(db.location.get(location_id, 'name'),))
    if have_new_description:
        email_details.append('Problem Description: %s' % 

    # Add messages (Update/Resolution) if there are any.
    messages = newvalues.db.msg
    for msgid in new_messages:
        content = messages.get(msgid, 'content', '')
        if content:
            email_details.append('Update/Resolution: %s' % (content,))

    return '\n\n'.join(email_details)

This example of real code stores the lines of the email in
the email_details list. It checks carefully to see if there is a new
description, then adds the contents of several fields, and appends the
nosy meessages. The return joins the lines together to return a
string. [The final version of this code will include additional

An example email is attached. Note that the code and the email differ
now, but will match when I finish with this tracker. I redacted where
the email was sent and the person that responded to the email.
Date User Action Args
2019-01-08 19:50:23tekbergsetrecipients: + tekberg, rouilj
2019-01-08 19:50:22tekbergsetmessageid: <>
2019-01-08 19:50:22tekberglinkissue2551018 messages
2019-01-08 19:50:22tekbergcreate