Skip to content
Snippets Groups Projects
Commit 11645da6 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

cron job for refreshing redcap data

parent ecd88318
No related branches found
No related tags found
1 merge request!65Simple connection to RED Cap
......@@ -71,7 +71,8 @@ TEMPLATES = [
]
CRON_CLASSES = [
'web.views.kit.KitRequestEmailSendJob'
'web.views.kit.KitRequestEmailSendJob',
'web.redcap_connector.RedCapRefreshJob'
]
# Password validation
......
......@@ -5,6 +5,7 @@ import logging
import pycurl
import certifi
from django_cron import CronJobBase, Schedule
from web.models import ConfigurationItem, Subject, Language
from web.models.constants import REDCAP_TOKEN_CONFIGURATION_TYPE, \
......@@ -302,3 +303,21 @@ class RedcapConnector(object):
return False
return True
class RedCapRefreshJob(CronJobBase):
RUN_EVERY_MINUTES = 60
schedule = Schedule(run_every_mins=RUN_EVERY_MINUTES)
code = 'web.red_cap_hourly_refresh' # a unique code
def do(self):
connector = RedcapConnector()
if connector.is_valid():
logger.info("Refreshing redcap data")
connector.refresh_inconsistent()
connector.refresh_missing()
logger.info("Redcap data refreshed")
return "ok"
else:
logger.info("Redcap connector is down")
return "connector down"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment