witten
/
luminotes
Archived
1
0
Fork 0

Fixed bug where recent notes were ordered by creation time instead of revision time.

This commit is contained in:
Dan Helfman 2008-04-18 20:39:23 +00:00
parent c488864273
commit eb587fc44f
4 changed files with 19 additions and 9 deletions

View File

@ -118,7 +118,7 @@ class Notebooks( object ):
if not notebook:
raise Access_error()
if notebook.name != u"Luminotes":
result[ "recent_notes" ] = self.__database.select_many( Note, notebook.sql_load_recent_notes( start = 0, count = 10 ) )
result[ "recent_notes" ] = self.__database.select_many( Note, notebook.sql_load_notes( start = 0, count = 10 ) )
# if the user doesn't have any storage bytes yet, they're a new user, so see what type of
# conversion this is (demo or signup)

View File

@ -216,7 +216,7 @@ class Test_controller( object ):
Note.sql_load_revisions = lambda self: \
lambda database: sql_load_revisions( self, database )
def sql_load_notes( self, database ):
def sql_load_notes( self, start, count, database ):
notes = []
for ( object_id, obj_list ) in database.objects.items():
@ -225,10 +225,13 @@ class Test_controller( object ):
notes.append( obj )
notes.sort( lambda a, b: -cmp( a.revision, b.revision ) )
return notes
if count is None:
return notes[ start : ]
else:
return notes[ start : start + count ]
Notebook.sql_load_notes = lambda self: \
lambda database: sql_load_notes( self, database )
Notebook.sql_load_notes = lambda self, start = 0, count = None: \
lambda database: sql_load_notes( self, start, count, database )
def sql_load_startup_notes( self, database ):
notes = []

View File

@ -100,11 +100,16 @@ class Notebook( Persistent ):
def sql_update( self ):
return self.sql_create()
def sql_load_notes( self ):
def sql_load_notes( self, start = 0, count = None ):
"""
Return a SQL string to load a list of all the notes within this notebook.
"""
return "select id, revision, title, contents, notebook_id, startup, deleted_from_id, rank, user_id from note_current where notebook_id = %s order by revision desc;" % quote( self.object_id )
if count is not None:
limit_clause = " limit %s" % count
else:
limit_clause = ""
return "select id, revision, title, contents, notebook_id, startup, deleted_from_id, rank, user_id from note_current where notebook_id = %s order by revision desc offset %s%s;" % ( quote( self.object_id ), start, limit_clause )
def sql_load_non_startup_notes( self ):
"""

View File

@ -26,6 +26,8 @@ class Notebook_rss( Rss_channel ):
invites = None,
invite_id = None,
after_login = None,
signup_plan = None,
recent_notes = None,
):
if notebook.name == u"Luminotes":
notebook_path = u"/"
@ -47,7 +49,7 @@ class Notebook_rss( Rss_channel ):
title = cgi.escape( note.title ),
link = u"%s?note_id=%s" % ( notebook_path, note.object_id ),
description = cgi.escape( note.contents ),
date = note.creation.strftime( "%Y-%m-%dT%H:%M:%SZ" ),
date = ( note.creation or note.revision ).strftime( "%Y-%m-%dT%H:%M:%SZ" ),
guid = u"%s?note_id=%s" % ( notebook_path, note.object_id ),
) for note in notes ],
) for note in recent_notes or notes ],
)