This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Order pending requests by today's date a little more sanely.

  • Loading branch information...
Jeremy Latt
Jeremy Latt committed Feb 28, 2011
1 parent baf45e8 commit 4d90fc7cc0d84f6fc18e8cd34f1fb5b29fa07ca8
Showing with 19 additions and 18 deletions.
  1. +2 −2 index.yaml
  2. +1 −1 pushmaster/config.py
  3. +7 −0 pushmaster/logic.py
  4. +2 −8 pushmaster/model.py
  5. +5 −4 pushmaster/query.py
  6. +2 −3 pushmaster/util.py
View
@@ -32,12 +32,12 @@ indexes:
properties:
- name: owner
- name: state
- - name: mtime
+ - name: ctime
direction: desc
- kind: Request
properties:
- name: owner
- name: state
- - name: ctime
+ - name: mtime
direction: desc
View
@@ -1,6 +1,6 @@
import os
import timezone
-from model import ConfigModel
+from pushmaster.model import ConfigModel
try:
is_dev = os.environ['SERVER_SOFTWARE'].startswith('Dev')
View
@@ -73,6 +73,8 @@ def create_push(name=None):
push = model.Push(name=name)
push.put()
+ push.bust_push_caches()
+ query.bust_push_caches()
return push
@@ -86,6 +88,8 @@ def abandon_push(push):
request.put()
push.put()
+ query.bust_push_caches()
+ query.bust_push_caches()
query.bust_request_caches()
push.bust_requests_cache()
@@ -148,6 +152,7 @@ def send_to_stage(push, stage):
push.stage = stage
push.put()
+ query.bust_push_caches()
for request in checkedin_requests:
request.state = 'onstage'
@@ -211,6 +216,7 @@ def send_to_live(push):
push.ltime = datetime.datetime.utcnow()
push.put()
+ push.bust_push_caches()
push.bust_requests_cache()
return push
@@ -270,6 +276,7 @@ def force_live(push):
push.ltime = push.mtime
push.put()
+ push.bust_push_caches()
return push
View
@@ -3,9 +3,8 @@
from google.appengine.api import memcache
from google.appengine.ext import db
-import query
-import timezone
-import urls
+
+from pushmaster import urls
__author__ = 'Jeremy Latt <jlatt@yelp.com>'
@@ -78,11 +77,6 @@ def can_change_owner(self):
def api_uri(self):
return urls.api_push(self)
- def put(self):
- try:
- return super(Push, self).put()
- finally:
- query.bust_push_caches()
@property
def json(self):
View
@@ -3,8 +3,8 @@
from google.appengine.api import memcache
from google.appengine.ext import db
-import model
-import timezone
+from pushmaster import model, timezone, util
+
CACHE_SECONDS = 60 * 60 * 24
@@ -65,9 +65,10 @@ def current_requests():
requests = memcache.get(CURRENT_REQUESTS_CACHE_KEY)
if requests is None:
requests = model.Request.all().filter('state =', 'requested')
- requests = sorted(requests, key=lambda r: (not r.urgent, r.target_date, not r.tests_pass, r.mtime))
memcache.add('request-current', requests, CACHE_SECONDS)
-
+ today = util.tznow().date()
+ request_key = lambda r: (not r.urgent, today if r.target_date < today else r.target_date, not r.tests_pass, r.mtime)
+ requests = sorted(requests, key=request_key)
return requests
def pending_requests(not_after=None):
View
@@ -6,9 +6,8 @@
from google.appengine.api import xmpp
from google.appengine.api.labs import taskqueue
-import config
-import timezone
-import urls
+from pushmaster import config, timezone, urls
+
log = logging.getLogger('pushmaster.util')

0 comments on commit 4d90fc7

Please sign in to comment.