def update_stats(self): save = [] self.fixture_offset = Setting.get_by_key_name('fixture_offset') if self.fixture_offset.status != "update_stats": logging.warning('Update Stats Job Hit Twice In A Row') print "error -- current status: ", self.fixture_offset.status return False (this_account, this_user, this_quiz_taker) = memcache.get('current_fixture') logging.info('Updating User Stats for User %s', this_user.unique_identifier) from quiztaker.methods import ProficiencyLevels pl = ProficiencyLevels() pl.set_for_user(this_quiz_taker) from accounts.methods import Awards awards = Awards() # check for new awards new_awards = awards.check_all(this_quiz_taker) from accounts.methods import Sponsorships sponsorships = Sponsorships() # check for new sponsorships, both personal and business new_sponsorships = sponsorships.check_user(this_user) self.fixture_offset.value += 1 self.fixture_offset.status = "create_account" save.append(self.fixture_offset) db.put(self.fixture_offset) return new_awards, new_sponsorships
def set_awards(self, *args): from utils.appengine_utilities.sessions import Session self.session = Session() if not self.session['user']: return "Not Logged In" from accounts.methods import Awards from model.user import QuizTaker awards = Awards() return awards.check_all( QuizTaker.get_by_key_name(self.session['user'].unique_identifier) )
def update_user_awards(self): from accounts.methods import Awards awards = Awards() # check for new awards logging.info('Updating Awards for User %s', self.session['user'].unique_identifier) from model.quiz import QuizTaker qt = QuizTaker.get_by_key_name(self.session['user'].unique_identifier) new_awards = awards.check_all(qt) if new_awards > 0: self.session['flash_msg'] = 'new_award' print "OK" return "OK"