Skip to content

Commit

Permalink
test dm
Browse files Browse the repository at this point in the history
  • Loading branch information
JoinTyang committed Jan 9, 2025
1 parent f7f69aa commit f129de1
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 72 deletions.
26 changes: 13 additions & 13 deletions seahub/utils/ccnet_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def get_ccnet_db_name():
return os.environ.get('SEAFILE_MYSQL_DB_CCNET_DB_NAME', '') or 'ccnet_db'
return os.environ.get('SEAFILE_MYSQL_DB_CCNET_DB_NAME', '') or 'SYSDBA'


class CcnetGroup(object):
Expand Down Expand Up @@ -40,9 +40,9 @@ def list_org_departments(self, org_id):
SELECT
g.group_id, group_name, creator_name, timestamp, type, parent_group_id
FROM
`{self.db_name}`.`OrgGroup` o
{self.db_name}.OrgGroup o
LEFT JOIN
`{self.db_name}`.`Group` g
{self.db_name}.Group g
ON o.group_id=g.group_id
WHERE
org_id={org_id} AND parent_group_id<>0;
Expand Down Expand Up @@ -93,9 +93,9 @@ def search(q):
count_sql = f"""
SELECT count(1)
FROM
`{self.db_name}`.`EmailUser` t1
{self.db_name}.EmailUser t1
LEFT JOIN
`{self.db_name}`.`UserRole` t2
{self.db_name}.UserRole t2
ON
t1.email = t2.email
WHERE
Expand All @@ -106,9 +106,9 @@ def search(q):
sql = f"""
SELECT t1.id, t1.email, t1.is_staff, t1.is_active, t1.ctime, t2.role, t1.passwd
FROM
`{self.db_name}`.`EmailUser` t1
{self.db_name}.EmailUser t1
LEFT JOIN
`{self.db_name}`.`UserRole` t2
{self.db_name}.UserRol t2
ON
t1.email = t2.email
WHERE
Expand Down Expand Up @@ -152,7 +152,7 @@ def get_group_ids_admins_map(self, group_ids):
sql = f"""
SELECT user_name, group_id
FROM
`{self.db_name}`.`GroupUser`
{self.db_name}.GroupUser
WHERE
group_id IN ({group_ids_str}) AND is_staff = 1
"""
Expand All @@ -168,15 +168,15 @@ def get_group_ids_admins_map(self, group_ids):

def change_groups_into_departments(self, group_id):
sql = f"""
UPDATE `{self.db_name}`.`Group` g
UPDATE {self.db_name}.Group g
SET
g.creator_name = 'system admin',
g.parent_group_id = -1
WHERE
g.group_id = {group_id}
"""
structure_sql = f"""
INSERT INTO `{self.db_name}`.`GroupStructure` (group_id, path)
INSERT INTO {self.db_name}.GroupStructure (group_id, path)
VALUES ('{group_id}', '{group_id}')
"""

Expand All @@ -190,8 +190,8 @@ def get_active_users_by_user_list(self, user_list):
user_list_str = ','.join(["'%s'" % str(user) for user in user_list])
active_users = []
sql = f"""
SELECT `email`
FROM `{self.db_name}`.`EmailUser`
SELECT email
FROM {self.db_name}.EmailUser
WHERE
email IN ({user_list_str}) AND is_active = 1 AND email NOT LIKE '%%@seafile_group'
"""
Expand All @@ -204,7 +204,7 @@ def get_active_users_by_user_list(self, user_list):

def get_org_user_count(self, org_id):
sql = f"""
SELECT COUNT(1) FROM `{self.db_name}`.`OrgUser` WHERE org_id={org_id}
SELECT COUNT(1) FROM {self.db_name}.OrgUser WHERE org_id={org_id}
"""
user_count = 0
with connection.cursor() as cursor:
Expand Down
Loading

0 comments on commit f129de1

Please sign in to comment.