-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download rate limit #404
base: master
Are you sure you want to change the base?
Download rate limit #404
Conversation
statistics/counter.py
Outdated
# Update UserTraffic | ||
for row in local_traffic_info[date_str]: | ||
trans_count += 1 | ||
org_id = row[0] | ||
user = row[1] | ||
oper = row[2] | ||
size = local_traffic_info[date_str][row] | ||
if oper in self.download_type_list: | ||
traffic_threshold = traffic_info_dict[user]['monthly_rate_limit'] if traffic_info_dict else 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
statistics/counter.py
Outdated
|
||
try: | ||
# Check the download traffic for the current month. | ||
if (not (org_id > 0) and oper in self.download_type_list and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not (org_id > 0) 换成org_id<0吧
statistics/counter.py
Outdated
return traffic_info_list | ||
|
||
|
||
def reset_download_rate_limit(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样重置限速是不是不合理?因为限速信息是在内存里,服务器重启的话,这些用户的限速就解除不了了吧
statistics/counter.py
Outdated
try: | ||
seahub_api = SeahubAPI() | ||
download_traffic_info = format_download_traffic_info(local_traffic_info, date_str, self.download_type_list) | ||
traffic_info_dict = seahub_api.get_download_rate_limit_info(download_traffic_info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里把所有有下载记录的用户都传过去,来获取每个人的限速信息,是不是得调整一下?改成只获取角色的限速信息,具体这个用户限速多少,在seafevents 中进行处理是不是更合适
statistics/counter.py
Outdated
org = ccnet_api.get_org_by_id(org_id) | ||
org_users = ccnet_api.get_org_emailusers(org.url_prefix, -1, -1) | ||
org_user_list[org_id] = org_users | ||
return org_user_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
变量名需要改一下,返回的并不是列表类型,接收这个函数返回值的变量名也要修改,查询是不是不用ccnet_api了?改成直接查数据库吧,查询角色的也需要改一下
statistics/counter.py
Outdated
UserTraffic.org_id == org_id, | ||
UserTraffic.op_type.in_(self.download_type_list) | ||
) | ||
monthly_result = self.edb_session.scalars(stmt2).first() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
变量名改成user_monthly_traffic_size
statistics/counter.py
Outdated
try: | ||
# Check org download traffic for current month. | ||
if (org_id > 0 and oper in self.download_type_list and | ||
(org_id not in rate_limit_orgs or not rate_limit_orgs[org_id])): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是不是可以用 rate_limit_orgs.get(org) 这种形式替换一下?
No description provided.