def get(self):
from services.github import GithubClient
last_date = self.request.get('date')
if last_date:
last_date = tools.fromISODate(last_date)
else:
last_date = (datetime.today() - timedelta(days=1))
users = User.SyncActive('github')
res = {}
td_put = []
for user in users:
gh_client = GithubClient(user)
if gh_client._can_run():
date_range = [(last_date - timedelta(days=x)).date() for x in range(self.GH_COMMIT_OVERLAP)]
logging.debug("Running SyncGithub cron for %s on %s..." % (user, date_range))
commits_dict = gh_client.get_contributions_on_date_range(date_range)
if commits_dict is not None:
for date, n_commits in commits_dict.items():
td = TrackingDay.Create(user, date)
td.set_properties({
'commits': n_commits
})
td_put.append(td)
else:
logging.debug("Github updater can't run")
if td_put:
ndb.put_multi(td_put)
self.json_out(res)
评论列表
文章目录