@@ -0,0 +1,1692 @@
+from totalimpactwebapp.user import User%0Afrom totalimpactwebapp import db%0Aimport datetime%0A%0Afrom tasks import update_from_linked_account%0A%0A%0A%22%22%22%0Arequires these env vars be set in this environment:%0ADATABASE_URL%0A%22%22%22%0A%0A# TBD%0A# should this be in webapp library?  if not, implications for logging%0A# should we have a library for these scripts, somewhere to put page_query?%0A%0Adef page_query(q):%0A    offset = 0%0A    while True:%0A        r = False%0A        for elem in q.limit(100).offset(offset):%0A           r = True%0A           yield elem%0A        offset += 100%0A        if not r:%0A            break%0A%0A%0Adef put_linked_account_users_on_queue():%0A%0A    i = 0%0A    # now = datetime.datetime.utcnow().isoformat()%0A    now = %222013-06-24%22%0A    # for user in page_query(User.query.filter(User.next_refresh %3C now).order_by(User.next_refresh.asc())):%0A%0A    # for user in page_query(User.query):%0A    for user in page_query(User.query.filter(User.next_refresh %3C= now)):%0A        linked_accounts_to_sync = %7B%0A            %22figshare%22: user.figshare_id, %0A            %22github%22: user.github_id, %0A            %22orcid%22: user.orcid_id, %0A            %22slideshare%22: user.slideshare_id %0A        %7D%0A        has_linked_account = %5Baccount for account in linked_accounts_to_sync if linked_accounts_to_sync%5Baccount%5D%5D%0A        if has_linked_account:%0A            i += 1%0A            print u%22%7Bi%7D user %7Burl_slug%7D has linked account: %7Bhas_linked_account%7D %7Bnext_refresh%7D %22.format(%0A                i=i, url_slug=user.url_slug, has_linked_account=has_linked_account, next_refresh=user.next_refresh)%0A            for account in has_linked_account:%0A                tiids = update_from_linked_account.delay(user, account)    %0A%0A%0Aput_linked_account_users_on_queue()%0A%0A%0A

add starter daily.py