Conversation
f5d6129 to
7d71681
Compare
6fab0c8 to
5a7a8a6
Compare
dtable_events/app/config.py
Outdated
|
|
||
| # env | ||
| ENV_SEAFILE_CENTRAL_CONF_DIR = os.environ.get('SEAFILE_CENTRAL_CONF_DIR', '') | ||
| ENV_CCNET_CONF_PATH = os.path.join(ENV_SEAFILE_CENTRAL_CONF_DIR, 'ccnet.conf') |
There was a problem hiding this comment.
ccnet.conf 已经弃用, 这个 不需要
| ccnet_db_name = ccnet_config.get('Database', 'DB', fallback='ccnet') | ||
| else: | ||
| ccnet_db_name = 'ccnet' | ||
| self.ccnet_db_name = ccnet_db_name |
There was a problem hiding this comment.
ccnet_db_name读取环境变量 SEATABLE_MYSQL_DB_CCNET_DB_NAME即可, 可以统一在 config.py 中进行定义和读取
| return row.automation_rules_limit_per_month | ||
| user = ccnet_api.get_emailuser(username) | ||
| user_role = user.role | ||
| return self.roles.get(user_role, {}).get('automation_rules_limit_per_month', -1) |
There was a problem hiding this comment.
self.roles --> self.get_roles()
| auto_rule_logger.info('rule %s not found', automation_rule_id) | ||
| return | ||
| if not rule: | ||
| return |
There was a problem hiding this comment.
if not rule 和上面56行一样, 可以删了
| if row and row.automation_rules_limit_per_month and row.automation_rules_limit_per_month != 0: | ||
| return row.automation_rules_limit_per_month | ||
| user = ccnet_api.get_emailuser(username) | ||
| user_role = user.role |
There was a problem hiding this comment.
user_role =user.role 这里 user.role 可能为空的, 此时获取不到设置的配额。 参考 dtable-web中的get_user_role函数的写法
| from dtable_events.utils import uuid_str_to_32_chars, get_dtable_owner_org_id | ||
|
|
||
|
|
||
| def can_trigger_by_dtable(dtable_uuid, db_session): |
There was a problem hiding this comment.
这里有一种场景: 系统管理员配置 role 的调用次数 (不通过编辑后台每个用户的次数,可能用户数量比较多)。 第一次配置role 100 次, 然后用户超过了之后, 系统管理员可能会改成 200 次, 而此时按理来说应该是可以触发规则的, 但是,这个函数的里面的is_exceed字段已经写死了。 这里函数参数可以增加一个 ENABLE_PERMISSION_ROLES的字典,直接可以用。
| if limit < 0: | ||
| return | ||
| usage, has_sent_warning = self.get_user_usage(db_session, username) | ||
| if usage >= limit: |
There was a problem hiding this comment.
这里最好也需要判断一下是否 has_sent_warning, 如果没有的话, 发送一个消息。 有一种情况, 比如我设置limit为3, 第一次触发33%, 第二次触发 66%, 第三次触发直接100%并且设置is_exceed了return了。 不会经过usage >= limit * 0.9下面发送通知。 这样逻辑会完备一点
98c7462 to
b15c3a9
Compare
fix update user auto-rules stats sql and opt auto-rules fix auto-rules scanner query stats fix unittest update is_exceed in new thread, add has_sent_warning field and send notification when auto rules trigger reach warning
…ning and drop AUTOMATION_ENABLED env
ffac0de to
1704a28
Compare
No description provided.