Shun Miyazawa 3 лет назад
Родитель
Сommit
d0d85228f6

+ 1 - 1
packages/app/src/server/models/activity.ts

@@ -116,7 +116,7 @@ activitySchema.statics.getPaginatedActivity = async function(limit: number, offs
   return paginateResult;
 };
 
-activitySchema.statics.getSnapshotUsernames = async function(q: string, option) {
+activitySchema.statics.findSnapshotUsernamesByUsernameRegex = async function(q: string, option) {
   const opt = option || {};
   const sortOpt = opt.sortOpt || { _id: 1 };
   const offset = opt.offset || 0;

+ 2 - 2
packages/app/src/server/routes/apiv3/users.js

@@ -963,7 +963,7 @@ module.exports = (crowi) => {
       }
 
       if (options.isIncludeActivitySnapshotUsernames && req.user.admin) {
-        const activitySnapshotUserData = await Activity.getSnapshotUsernames(q, { offset, limit });
+        const activitySnapshotUserData = await Activity.findSnapshotUsernamesByUsernameRegex(q, { offset, limit });
         Object.assign(data, { activitySnapshotUser: activitySnapshotUserData });
       }
 
@@ -978,7 +978,7 @@ module.exports = (crowi) => {
       return res.apiv3(data);
     }
     catch (err) {
-      logger.error('failed to get usernames', err);
+      logger.error('Failed to get usernames', err);
       return res.apiv3Err(err);
     }
   });

+ 4 - 3
packages/app/src/stores/user.tsx

@@ -16,7 +16,8 @@ export const useSWRxUsersList = (userIds: string[]): SWRResponse<IUserHasId[], E
   );
 };
 
-type usernameRequertOptions = {
+
+type usernameRequestOptions = {
   isIncludeActiveUsernames?: boolean,
   isIncludeInactiveUsernames?: boolean,
   isIncludeActivitySnapshotUsernames?: boolean,
@@ -28,14 +29,14 @@ type userData = {
   totalCount: number
 }
 
-type usernameResponse = {
+type usernameResult = {
   activeUser?: userData
   inactiveUser?: userData
   activitySnapshotUser?: userData
   mixedUsernames: string[]
 }
 
-export const useSWRxUsernames = (q: string, offset?: number, limit?: number, options?: usernameRequertOptions): SWRResponse<usernameResponse, Error> => {
+export const useSWRxUsernames = (q: string, offset?: number, limit?: number, options?: usernameRequestOptions): SWRResponse<usernameResult, Error> => {
   return useSWRImmutable(
     q != null ? ['/users/usernames', q, offset, limit, options] : null,
     (endpoint, q, offset, limit, options) => apiv3Get(endpoint, {