[MM-55017] Add API method to get users for Admin Reporting (#25499)

* Add store method to get reporting data

* Some store changes

* Added app layer

* Added API call, some miscellaneous fixes

* Fix lint

* Fix serialized check

* Add API docs

* Fix user store tests leaking users

* Fix test

* PR feedback

* Add filtering for role/team/activated user, filter out bot users

* Fix mock

* Fix test

* Oops

* Switch to using struct filter

* More PR feedback

* Fix gen

* Fix test

* Fix API docs

* Fix test

* Fix possible SQL injection, some query optimization

* Fix migrations

* Oops

* Add role to API

* Fix check

* Add Client4 API call for load testing

* Fix test

* Update server/channels/store/storetest/user_store.go

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>

* PR feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Этот коммит содержится в:
Devin Binnie
2023-12-08 10:30:08 -05:00
коммит произвёл GitHub
родитель 7afc14de36
Коммит 109f4643c6
26 изменённых файлов: 2399 добавлений и 1 удалений

Просмотреть файл

@@ -52,7 +52,7 @@ import {
ChannelSearchOpts,
ServerChannel,
} from '@mattermost/types/channels';
import {Options, StatusOK, ClientResponse, LogLevel, FetchPaginatedThreadOptions} from '@mattermost/types/client4';
import {Options, StatusOK, ClientResponse, LogLevel, FetchPaginatedThreadOptions, UserReportOptions} from '@mattermost/types/client4';
import {Compliance} from '@mattermost/types/compliance';
import {
ClientConfig,
@@ -133,6 +133,7 @@ import {
UserStatus,
GetFilteredUsersStatsOpts,
UserCustomStatus,
UserReport,
} from '@mattermost/types/users';
import {DeepPartial, RelationOneToOne} from '@mattermost/types/utilities';
import {ProductNotices} from '@mattermost/types/product_notices';
@@ -982,6 +983,14 @@ export default class Client4 {
);
};
getUsersForReporting = (filter: UserReportOptions) => {
const queryString = buildQueryString(filter);
return this.doFetch<UserReport[]>(
`${this.getUsersRoute()}/report${queryString}`,
{method: 'get'},
);
}
/**
* @deprecated
*/

Просмотреть файл

@@ -37,3 +37,23 @@ export type FetchPaginatedThreadOptions = {
fromCreateAt?: number;
fromPost?: string;
}
export enum ReportDuration {
Last30Days = 'last_30_days',
PreviousMonth = 'previous_month',
Last6Months = 'last_6_months',
}
export type UserReportOptions = {
sort_column: 'CreateAt' | 'Username' | 'FirstName' | 'LastName' | 'Nickname' | 'Email',
page_size: number,
sort_direction?: 'asc' | 'desc',
date_range?: ReportDuration,
last_column_value?: string,
last_id?: string,
role_filter?: string,
has_no_team?: boolean,
team_filter?: string,
hide_active?: boolean,
hide_inactive?: boolean,
}

Просмотреть файл

@@ -143,3 +143,16 @@ export type GetFilteredUsersStatsOpts = {
export type AuthChangeResponse = {
follow_link: string;
};
export type UserReport = {
id: string;
username: string;
email: string;
create_at: number;
display_name: string;
last_login_at: number;
last_status_at?: number;
last_post_date?: number;
days_active?: number;
total_posts?: number;
}