Opened 14 years ago

Closed 14 years ago

#67 closed defect (fixed)

Fix negative indexing in groups/diffs.py

Reported by: adehnert Owned by:
Priority: normal Milestone: Near Release
Component: Core Version:
Keywords: Cc:
Size: medium

Description

We're occasionally getting this traceback:

Traceback (most recent call last):
  File "./groups/diffs.py", line 248, in <module>
    generate_diffs()
  File "./groups/diffs.py", line 243, in generate_diffs
    diff_objects(objs, since=recent, callbacks=callbacks)
  File "./groups/diffs.py", line 213, in diff_objects
    after = after_versions[-1]
  File "/usr/lib/python2.7/site-packages/django/db/models/query.py", line 157, in __getitem__
    "Negative indexing is not supported."
AssertionError: Negative indexing is not supported.

(For example, https://diswww.mit.edu/menelaus/asa-db/736.)

We should fix this, and possibly make it robust enough to continue running even when something like that gets run into.

Change History (2)

comment:1 Changed 14 years ago by adehnert

  • Size set to medium

comment:2 Changed 14 years ago by adehnert

  • Resolution set to fixed
  • Status changed from new to closed
commit 80a8145220f7f238904f730367aed64d65635a94
Author: Alex Dehnert <adehnert@mit.edu>
Date:   Sun Feb 26 16:18:33 2012 -0500

    Fix new groups in groups/diffs.py (Trac: #67)
    
    This is three related fixes.
    
    The Trac issue is that it turns out Django doesn't like negative queryset
    indexes, so do a .reverse() and then a positive index...
    
    The second issue is that, even if the negative indexed worked, we wanted to
    be updating before, not after --- we want to set the original we're diffing
    against, not the current version, despite the fact that we're grabbing the
    original from after_versions instead of before_versions.
    
    Finally, the third issue is that the comment about the no-change case is
    misleading --- even when a group is just recognized, it still will have
    multiple versions. In particular, the startup form submission + the approval.
    This adds a clarifying comment.
Note: See TracTickets for help on using tickets.