~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/doc/bugtask-expiration.txt

  • Committer: Curtis Hovey
  • Date: 2011-08-18 20:56:37 UTC
  • mto: This revision was merged to the branch mainline in revision 13736.
  • Revision ID: curtis.hovey@canonical.com-20110818205637-ae0pf9aexdea2mlb
Cleaned up doctrings and hushed lint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Bugtask Expiration
2
 
==================
 
1
= Bugtask Expiration =
3
2
 
4
3
Old unattended Incomplete bugtasks clutter the search results of
5
4
Launchpad Bugs making the bug staff's job difficult. A script is run
22
21
all the rules stated above.
23
22
 
24
23
 
25
 
findExpirableBugTasks() Part 1
26
 
------------------------------
 
24
== findExpirableBugTasks() Part 1 ==
27
25
 
28
26
BugTaskSet provides findExpirableBugTasks() to find bugtasks that
29
27
qualify for expiration. The bugtasks must must meet all the
52
50
    >>> expirable_bugtasks.count()
53
51
    0
54
52
 
55
 
We need a function to reset the last_modified date of a bug because
56
 
setPrivate() now publishes an object modified event which will cause the
57
 
date_last_modified to be set to 'now'. We require some bugs used in this test
58
 
to be last modified in the past.
59
 
 
60
 
    >>> def reset_bug_modified_date(bug, days_ago):
61
 
    ...     from datetime import datetime, timedelta
62
 
    ...     import pytz
63
 
    ...     UTC = pytz.timezone('UTC')
64
 
    ...     date_modified = datetime.now(UTC) - timedelta(days=days_ago)
65
 
    ...     bug.date_last_updated = date_modified
66
 
 
67
 
 
68
 
Setup
69
 
-----
 
53
 
 
54
== Setup ==
70
55
 
71
56
Let's make some bugtasks that qualify for expiration. A Jokosher
72
57
bugtask and a conjoined pair of ubuntu_hoary and ubuntu bugtasks
244
229
    recent           False    31  Incomplete  False     False  False  False
245
230
    no_expire        False    61  Incomplete  False     False  False  False
246
231
 
247
 
isExpirable()
248
 
-------------
 
232
== isExpirable() ==
249
233
 
250
234
In addition to can_expire bugs have an isExpirable method to which a custom
251
235
number of days, days_old, can be passed.  days_old is then used with
261
245
    >>> very_old_bugtask.transitionToStatus(
262
246
    ...     BugTaskStatus.INVALID, sample_person)
263
247
 
264
 
    # Pass isExpirable() a days_old parameter, then set the bug to Invalid so
265
 
    # it doesn't affect the rest of the doctest.
 
248
    # Pass isExpirable() a days_old parameter, then set the bug to Invalid so it
 
249
    # doesn't affect the rest of the doctest
266
250
    >>> from lp.bugs.tests.bug import create_old_bug
267
251
    >>> not_so_old_bugtask = create_old_bug('expirable_distro', 31, ubuntu)
268
252
    >>> not_so_old_bugtask.bug.isExpirable(days_old=14)
271
255
    ...     BugTaskStatus.INVALID, sample_person)
272
256
 
273
257
 
274
 
findExpirableBugTasks() Part 2
275
 
------------------------------
 
258
== findExpirableBugTasks() Part 2 ==
276
259
 
277
260
The value of the min_days_old controls the bugtasks that are
278
261
returned. The oldest bug in this test is 351 days old, the youngest is
381
364
    ROLE         EXPIRE  AGE  STATUS      ASSIGNED  DUP    MILE   REPLIES
382
365
 
383
366
 
384
 
Privacy
385
 
-------
 
367
== Privacy ==
386
368
 
387
369
The user parameter indicates which user is performing the search. Only
388
370
bugs that the user has permission to view are returned. A value of None
396
378
 
397
379
If one of the bugs is set to private, anonymous users can no longer see
398
380
it as being marked for expiration.
399
 
We need a feature flag so that multi-pillar bugs can be made private.
400
 
 
401
 
    >>> from lp.services.features.testing import FeatureFixture
402
 
    >>> feature_flag = {
403
 
    ...     'disclosure.allow_multipillar_private_bugs.enabled': 'on'}
404
 
    >>> flags = FeatureFixture(feature_flag)
405
 
    >>> flags.setUp()
406
381
 
407
382
    >>> private_bug = ubuntu_bugtask.bug
408
383
    >>> private_bug.title
409
384
    u'expirable_distro'
410
385
    >>> private_bug.setPrivate(True, sample_person)
411
386
    True
412
 
    >>> reset_bug_modified_date(private_bug, 351)
413
387
 
414
388
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
415
389
    ...     0, user=None, target=ubuntu)
431
405
 
432
406
    >>> private_bug.subscribe(no_priv, sample_person)
433
407
    <lp.bugs.model.bugsubscription.BugSubscription ...>
434
 
    >>> reset_bug_modified_date(private_bug, 351)
435
408
    >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
436
409
    ...     0, user=no_priv, target=ubuntu)
437
410
    >>> visible_bugs = set(bugtask.bug for bugtask in expirable_bugtasks)
455
428
 
456
429
    >>> private_bug.setPrivate(False, sample_person)
457
430
    True
458
 
    >>> reset_bug_modified_date(private_bug, 351)
459
 
 
460
 
Clean up the feature flag.
461
 
    >>> flags.cleanUp()
462
 
 
463
 
 
464
 
The default expiration age
465
 
--------------------------
 
431
 
 
432
 
 
433
== The default expiration age ==
466
434
 
467
435
The expiration age is set using the
468
436
config.malone.days_before_expiration configuration variable. It
476
444
    60
477
445
 
478
446
 
479
 
Running the script
480
 
------------------
 
447
== Running the script ==
481
448
 
482
449
There are no Expired Bugtasks in sampledata, from the tests above.
483
450
 
522
489
    >>> bugtasks = [BugTask.get(bugtask.id) for bugtask in bugtasks]
523
490
 
524
491
 
525
 
After the script has run
526
 
------------------------
 
492
== After the script has run ==
527
493
 
528
494
There are three Expired bugtasks. Jokosher, hoary and ubuntu were
529
495
expired by the expiration process. Although ubuntu was never returned
545
511
    recent           False    31  Incomplete  False     False  False  False
546
512
    no_expire        False    61  Incomplete  False     False  False  False
547
513
 
 
514
The bugtasks statusexplanation was updated to explain the change in
 
515
status.
 
516
 
 
517
    >>> hoary_bugtask = BugTask.get(hoary_bugtask.id)
 
518
    >>> print hoary_bugtask.statusexplanation
 
519
    [Expired for Ubuntu Hoary because there has been no activity for 60 days.]
 
520
 
548
521
The message explaining the reason for the expiration was posted by the
549
522
Launchpad Janitor celebrity. Only one message was created for when the
550
523
master and slave bugtasks were expired.
570
543
    Launchpad Janitor  Ubuntu Hoary: status  Incomplete  Expired
571
544
 
572
545
 
573
 
enable_bug_expiration
574
 
---------------------
 
546
== enable_bug_expiration ==
575
547
 
576
548
The bugtask no_expiration_bugtask has not been expired because it does
577
549
not participate in bug expiration. When uses_bug_expiration is set to