Commits

Roma Sokolov  committed 7d73974

time for score; output datetime; fix ordering

  • Participants
  • Parent commits 3e9f35f

Comments (0)

Files changed (1)

 except ImportError:
     import config
 
-from utils import split_tags, uni
+from utils import split_tags, format_output
 
 
 app = Flask(config.NAME, config.STATIC_PATH)
 @split_tags
 def get(*tags):
     if tags:
-        page = request.args.get('page', 1)
+        page = int(request.args.get('page', 1))
         count = config.ITEMS_COUNT
 
         tempkey = str(time.time())
         storage.zinterstore(tempkey, tags, 'MAX')
-        result = storage.zrange(tempkey, (page - 1) * count,
-                                page * count)
+        start = (page - 1) * count
+        result = storage.zrevrange(tempkey, start,
+                                   (page * count) - 1,
+                                   True
+                                   )
         storage.delete(tempkey)
 
-        items = imap(uni, result)
+        items = imap(format_output, result)
 
         last_page = True if len(result) < count else False
 
         return render_template('list.html', tags=tags, page=page,
-                               items=items, last_page=last_page)
+                               start=start, last_page=last_page,
+                               items=items)
     else:
         return redirect(url_for('main'))
 
     if len(item) > 200:
         raise ValueError(u'Error! Remark can contain at most 200 characters.')
     for tag in tags:
-        storage.zadd(tag, item, 1) # TODO: fix it!
+        storage.zadd(tag, item, int(time.time()))
 
 
 @app.route('/about', methods=['GET'])