Wiki

Case Status Kiln
Register Log In

Wiki

 
Random Assignment
  • RSS Feed

Last modified on 9/30/2011 2:46 PM by User.

Tags:

Random Assignment

randomAssignment.py

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
"""
Random Assignment

When you have cases that are handled by multiple individuals on a team,
it can be difficult to distribute the tasks evenly to each member without
cherry picking or having someone manage the queue.

This script helps by taking cases assigned to an "Up For Grabs" user and
re-assigning them randomly to the members of the team, based on a specified
weight.

How to use this script:
1. Set up a Virtual User called "Up For Grabs" within FogBugz.
2. Make the "Up For Grabs" user the primary contact for the support area
   you are using.
3. Change the settings below to correspond to your installation.
4. Run this script using:
   > python randomAssignment.py
   
See https://developers.fogbugz.com/default.asp?W194 for more
information on using the FogBugz XML API with Python.
"""

IX_PERSON_UP_FOR_GRABS = 16 # the ixPerson value of the Up For Grabs user
IX_AREA_SUPPORT        = 36 # the ixArea value of the cases in your support queue
REPS = { 2 : ['Ben',1],     # a list of team members, using this format:
    4 : ['Fred', 4],        # { ixPerson : [name, weight]...
    3 : ['Barney', 1] ,     # the greater the weight value, the greater the chance
    8 : ['Wilma', 4] }      # the user will have the case assigned to him/her.

import re
from fogbugz import FogBugz
import fbSettings
import random

#log onto FogBugz  
fogbugz = FogBugz(fbSettings.URL, fbSettings.TOKEN)

#lottery is an array to help with randomness
lottery = []
#this will fill the lottery array with the ixPerson values in REPS,
#one for each "weight" value above
for rep in REPS:
    lottery.extend([rep] * REPS[rep][1])

#shuffle the list
random.shuffle(lottery)

searchString = 'area:"=%s" assignedto:"=%s"' % (IX_AREA_SUPPORT,IX_PERSON_UP_FOR_GRABS)
respUpForGrabs = fogbugz.search(q=searchString,
                                cols='ixBug,sTitle,ixPersonLastEditedBy')

i = 0
for case in respUpForGrabs.cases.childGenerator():
    target_rep = int(case.ixpersonlasteditedby.string)
    #if the person who last edited the case assigned it to the Up For Grabs user, 
    #we want to keep iterating through the lottery until we get a different user.
    while target_rep == int(case.ixpersonlasteditedby.string): 
        target_rep = lottery[i % len(lottery)]
        i += 1
    fogbugz.assign(ixBug=case.ixbug.string,ixPersonAssignedTo=target_rep)