本文整理汇总了Python中models.user.UserModel.getTrust方法的典型用法代码示例。如果您正苦于以下问题:Python UserModel.getTrust方法的具体用法?Python UserModel.getTrust怎么用?Python UserModel.getTrust使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.UserModel
的用法示例。
在下文中一共展示了UserModel.getTrust方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from models.user import UserModel [as 别名]
# 或者: from models.user.UserModel import getTrust [as 别名]
def __init__(self, question_id):
schedule_list = []
user_list = []
scores = []
answers = AnswerModel.get_question_answers(question_id)
for a in answers:
uid = a.userID
scores.append((UserModel.getTrust(uid), a))
user_list.append(a.userID)
scores.sort(key=lambda tup: tup[0])
# TODO: possibly change fixed percentage to variable
# IMPORTANT: users that did not give an answer should be able to rate,
# not sure if that will happen right now
#
# initial scheduler
shift_count = len(scores) - max(1, int(len(scores) * 0.2))
user_list = user_list[shift_count:] + user_list[0:shift_count]
for x in xrange(0, len(scores)):
a_id = scores[x][1].id
u_id = user_list[x]
schedule_list.append((a_id, u_id))
Schedule.add_list(schedule_list)
示例2: calc_new_rating
# 需要导入模块: from models.user import UserModel [as 别名]
# 或者: from models.user.UserModel import getTrust [as 别名]
def calc_new_rating(self):
K = UserModel.getTrust(self.user_id) / 20.0
new_rating = AnswerModel.new_rating(self.best_answer_id, self.other_answer_id, K)
AnswerModel.set_ranking(self.best_answer_id, new_rating[0])
AnswerModel.set_ranking(self.other_answer_id, new_rating[1])
示例3: updateTrust
# 需要导入模块: from models.user import UserModel [as 别名]
# 或者: from models.user.UserModel import getTrust [as 别名]
def updateTrust(self):
trust = UserModel.getTrust(self.user_id) + ((float(self.rating) * 25.0) - 75.0)
UserModel.setTrust(self.user_id, trust)