Guest User

Untitled

a guest
Jul 12th, 2020
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1.  statistic_model = apps.get_model('user', 'StatisticModel')
  2.         statistics = statistic_model.objects.all()
  3.  
  4.         for user in statistics:
  5.             now = time.time()
  6.             last_action = time.mktime(user.time_offline.timetuple())
  7.             offline_time = Decimal(now - last_action)
  8.  
  9.             income = int(user.income * offline_time)
  10.  
  11.             reputation_speed = formula.reputation(income, user.future_reputation)
  12.             reputation_speed = USER_REPUTATION_SPEED_BONUS(user.user_id, reputation_speed)
  13.  
  14.             user.budget += income
  15.             user.budget_session += income
  16.             user.budget_total += income
  17.             user.reputation_speed = reputation_speed
  18.             user.future_reputation += reputation_speed
  19.  
  20.         statistic_model.objects.bulk_update(statistics, ['time_offline', 'budget', 'budget_session', 'budget_total', 'reputation_speed', 'future_reputation'], batch_size=1000)
Advertisement
Add Comment
Please, Sign In to add comment