New report router and user reporting refactoring (#25713)

* Added materialized view migration

* Renamed mat view

* Added channel membership mat view and indexes

* Added channel membership mat view and indexes

* Added new index

* WIP

* Simplifying user reporting code

* Created app and API layer for cahnnel reporting, reporting refactoring in general

* New router

* Remobved channel reporting meanwhile

* Upodated autogenerated stuff

* Lint fix

* Fixed typo

* api vet

* i18n fix

* Fixed API vetting and removed channel reporting constants

* yaml

* removed app pagination tests
Этот коммит содержится в:
Harshil Sharma
2023-12-14 21:19:19 +05:30
коммит произвёл GitHub
родитель 32880efa25
Коммит 97a23d791e
16 изменённых файлов: 380 добавлений и 1339 удалений

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

@@ -48,10 +48,6 @@ const (
PushThreadsNotifyProp = "push_threads"
EmailThreadsNotifyProp = "email_threads"
ReportDurationLast30Days = "last_30_days"
ReportDurationPreviousMonth = "previous_month"
ReportDurationLast6Months = "last_6_months"
DefaultLocale = "en"
UserAuthServiceEmail = "email"
@@ -71,10 +67,6 @@ const (
DesktopTokenTTL = time.Minute * 3
)
var (
UserReportSortColumns = []string{"CreateAt", "Username", "FirstName", "LastName", "Nickname", "Email", "Roles"}
)
//msgp:tuple User
// User contains the details about the user.
@@ -1029,74 +1021,3 @@ type UserPostStats struct {
DaysActive *int `json:"days_active,omitempty"`
TotalPosts *int `json:"total_posts,omitempty"`
}
type UserReportQuery struct {
User
UserPostStats
}
type UserReport struct {
Id string `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
CreateAt int64 `json:"create_at,omitempty"`
DisplayName string `json:"display_name"`
Roles string `json:"roles"`
UserPostStats
}
type UserReportOptionsWithoutDateRange struct {
SortColumn string
SortDesc bool
PageSize int
LastSortColumnValue string
LastUserId string
Role string
Team string
HasNoTeam bool
HideActive bool
HideInactive bool
}
type UserReportOptions struct {
UserReportOptionsWithoutDateRange
StartAt int64
EndAt int64
}
type UserReportOptionsAPI struct {
UserReportOptionsWithoutDateRange
DateRange string
}
func (u *UserReportOptionsAPI) ToBaseOptions(now time.Time) *UserReportOptions {
startAt := int64(0)
endAt := int64(0)
if u.DateRange == ReportDurationLast30Days {
startAt = now.AddDate(0, 0, -30).UnixMilli()
} else if u.DateRange == ReportDurationPreviousMonth {
startOfMonth := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, time.Local)
startAt = startOfMonth.AddDate(0, -1, 0).UnixMilli()
endAt = startOfMonth.UnixMilli()
} else if u.DateRange == ReportDurationLast6Months {
startAt = now.AddDate(0, -6, -0).UnixMilli()
}
return &UserReportOptions{
UserReportOptionsWithoutDateRange: u.UserReportOptionsWithoutDateRange,
StartAt: startAt,
EndAt: endAt,
}
}
func (u *UserReportQuery) ToReport() *UserReport {
return &UserReport{
Id: u.Id,
Username: u.Username,
Email: u.Email,
CreateAt: u.CreateAt,
DisplayName: u.GetDisplayName(ShowNicknameFullName),
Roles: u.Roles,
UserPostStats: u.UserPostStats,
}
}