Skip to content

Commit

Permalink
Adding 6 hour cron job for statistics calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
sfederwisch committed May 30, 2014
1 parent 4101a8b commit 65ae3bc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
27 changes: 27 additions & 0 deletions core/controllers/cron.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2014 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Controllers for the cron jobs."""

from core.controllers import base
from core import jobs_registry

class StatisticsHandler(base.BaseHandler):
"""Handler for statistics cron job."""
def get(self):
"""Handles get requests."""
for klass in jobs_registry.JOB_MANAGER_CLASSES:
if klass.__name__ == 'StatisticsPageJobManager':
klass.enqueue(klass.create_new())
break
4 changes: 4 additions & 0 deletions cron.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cron:
- description: periodic statistics calculations
url: /cron/statistics
schedule: every 6 hours
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from core.controllers import admin
from core.controllers import base
from core.controllers import cron
from core.controllers import editor
from core.controllers import galleries
from core.controllers import moderator
Expand Down Expand Up @@ -149,6 +150,8 @@ def ui_access_wrapper(self, *args, **kwargs):
get_redirect_route(r'/admin', admin.AdminPage, 'admin_page'),
get_redirect_route(r'/adminhandler', admin.AdminHandler, 'admin_handler'),

get_redirect_route(r'/cron/statistics', cron.StatisticsHandler, 'statistics_handler'),

get_redirect_route(
r'/imagehandler/<exploration_id>/<encoded_filepath>',
resources.ImageHandler, 'image_handler'),
Expand Down

0 comments on commit 65ae3bc

Please sign in to comment.