mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 07:19:25 -05:00
ads: Add endpoint for health check on ads
Adds a new route /health/ads which returns in plain text the seconds since the epoch that the ad system was last updated via make_daily_promotions()
This commit is contained in:
committed by
bsimpson63
parent
82014d80b1
commit
81891ea4d7
@@ -158,6 +158,7 @@ def make_map():
|
||||
mc('/promoted/', controller='promoted', action="listing", sort="")
|
||||
|
||||
mc('/health', controller='health', action='health')
|
||||
mc('/health/ads', controller='health', action='promohealth')
|
||||
|
||||
mc('/', controller='hot', action='listing')
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ from pylons import c, g, response
|
||||
|
||||
from reddit_base import MinimalController
|
||||
from r2.lib.amqp import worker
|
||||
from r2.lib import promote
|
||||
|
||||
from validator import *
|
||||
|
||||
@@ -47,3 +48,7 @@ class HealthController(MinimalController):
|
||||
c.dontcache = True
|
||||
response.headers['Content-Type'] = 'text/plain'
|
||||
return json.dumps(g.versions, sort_keys=True, indent=4)
|
||||
|
||||
def GET_promohealth(self):
|
||||
response.headers['Content-Type'] = 'text/plain'
|
||||
return json.dumps(promote.health_check())
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
from __future__ import with_statement
|
||||
|
||||
import json
|
||||
import time
|
||||
|
||||
from r2.models import *
|
||||
from r2.models.bidding import SponsorBoxWeightings, WeightingRef
|
||||
from r2.models.keyvalue import NamedGlobals
|
||||
from r2.lib.wrapped import Wrapped
|
||||
from r2.lib import authorize
|
||||
from r2.lib import emailer, filters
|
||||
@@ -54,6 +56,16 @@ CAMPAIGN = Enum("start", "end", "bid", "sr", "trans_id")
|
||||
UPDATE_QUEUE = 'update_promos_q'
|
||||
QUEUE_ALL = 'all'
|
||||
|
||||
PROMO_HEALTH_KEY = 'promotions_last_updated'
|
||||
|
||||
|
||||
def _mark_promos_updated():
|
||||
NamedGlobals.set(PROMO_HEALTH_KEY, time.time())
|
||||
|
||||
|
||||
def health_check():
|
||||
return NamedGlobals.get(PROMO_HEALTH_KEY, default=0)
|
||||
|
||||
|
||||
@memoize("get_promote_srid")
|
||||
def get_promote_srid(name = 'promos'):
|
||||
@@ -831,6 +843,7 @@ def make_daily_promotions(offset = 0, test = False):
|
||||
|
||||
if not test:
|
||||
set_live_promotions(all_links, weighted)
|
||||
_mark_promos_updated()
|
||||
else:
|
||||
print (all_links, weighted)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user