Adding go vet from hack-a-thon (#5328)
* Adding go vet to the api package * Adding go vet to app package * Adding go vet to manualtesting package * Adding go vet to the model package * Adding go vet to the store dir * Adding go vet to utils package * Adding missing dirs with go files * Fixing up makefile * Fixing up makefile * Removing root dir
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
432dc9239f
Коммит
1359f7f391
@@ -31,16 +31,16 @@ func GetAnalytics(name string, teamId string) (model.AnalyticsRows, *model.AppEr
|
||||
|
||||
if name == "standard" {
|
||||
var rows model.AnalyticsRows = make([]*model.AnalyticsRow, 10)
|
||||
rows[0] = &model.AnalyticsRow{"channel_open_count", 0}
|
||||
rows[1] = &model.AnalyticsRow{"channel_private_count", 0}
|
||||
rows[2] = &model.AnalyticsRow{"post_count", 0}
|
||||
rows[3] = &model.AnalyticsRow{"unique_user_count", 0}
|
||||
rows[4] = &model.AnalyticsRow{"team_count", 0}
|
||||
rows[5] = &model.AnalyticsRow{"total_websocket_connections", 0}
|
||||
rows[6] = &model.AnalyticsRow{"total_master_db_connections", 0}
|
||||
rows[7] = &model.AnalyticsRow{"total_read_db_connections", 0}
|
||||
rows[8] = &model.AnalyticsRow{"daily_active_users", 0}
|
||||
rows[9] = &model.AnalyticsRow{"monthly_active_users", 0}
|
||||
rows[0] = &model.AnalyticsRow{Name: "channel_open_count", Value: 0}
|
||||
rows[1] = &model.AnalyticsRow{Name: "channel_private_count", Value: 0}
|
||||
rows[2] = &model.AnalyticsRow{Name: "post_count", Value: 0}
|
||||
rows[3] = &model.AnalyticsRow{Name: "unique_user_count", Value: 0}
|
||||
rows[4] = &model.AnalyticsRow{Name: "team_count", Value: 0}
|
||||
rows[5] = &model.AnalyticsRow{Name: "total_websocket_connections", Value: 0}
|
||||
rows[6] = &model.AnalyticsRow{Name: "total_master_db_connections", Value: 0}
|
||||
rows[7] = &model.AnalyticsRow{Name: "total_read_db_connections", Value: 0}
|
||||
rows[8] = &model.AnalyticsRow{Name: "daily_active_users", Value: 0}
|
||||
rows[9] = &model.AnalyticsRow{Name: "monthly_active_users", Value: 0}
|
||||
|
||||
openChan := Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
|
||||
privateChan := Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
|
||||
@@ -139,7 +139,7 @@ func GetAnalytics(name string, teamId string) (model.AnalyticsRows, *model.AppEr
|
||||
return rows, nil
|
||||
} else if name == "post_counts_day" {
|
||||
if skipIntensiveQueries {
|
||||
rows := model.AnalyticsRows{&model.AnalyticsRow{"", -1}}
|
||||
rows := model.AnalyticsRows{&model.AnalyticsRow{Name: "", Value: -1}}
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func GetAnalytics(name string, teamId string) (model.AnalyticsRows, *model.AppEr
|
||||
}
|
||||
} else if name == "user_counts_with_posts_day" {
|
||||
if skipIntensiveQueries {
|
||||
rows := model.AnalyticsRows{&model.AnalyticsRow{"", -1}}
|
||||
rows := model.AnalyticsRows{&model.AnalyticsRow{Name: "", Value: -1}}
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
@@ -161,12 +161,12 @@ func GetAnalytics(name string, teamId string) (model.AnalyticsRows, *model.AppEr
|
||||
}
|
||||
} else if name == "extra_counts" {
|
||||
var rows model.AnalyticsRows = make([]*model.AnalyticsRow, 6)
|
||||
rows[0] = &model.AnalyticsRow{"file_post_count", 0}
|
||||
rows[1] = &model.AnalyticsRow{"hashtag_post_count", 0}
|
||||
rows[2] = &model.AnalyticsRow{"incoming_webhook_count", 0}
|
||||
rows[3] = &model.AnalyticsRow{"outgoing_webhook_count", 0}
|
||||
rows[4] = &model.AnalyticsRow{"command_count", 0}
|
||||
rows[5] = &model.AnalyticsRow{"session_count", 0}
|
||||
rows[0] = &model.AnalyticsRow{Name: "file_post_count", Value: 0}
|
||||
rows[1] = &model.AnalyticsRow{Name: "hashtag_post_count", Value: 0}
|
||||
rows[2] = &model.AnalyticsRow{Name: "incoming_webhook_count", Value: 0}
|
||||
rows[3] = &model.AnalyticsRow{Name: "outgoing_webhook_count", Value: 0}
|
||||
rows[4] = &model.AnalyticsRow{Name: "command_count", Value: 0}
|
||||
rows[5] = &model.AnalyticsRow{Name: "session_count", Value: 0}
|
||||
|
||||
iHookChan := Srv.Store.Webhook().AnalyticsIncomingCount(teamId)
|
||||
oHookChan := Srv.Store.Webhook().AnalyticsOutgoingCount(teamId)
|
||||
|
||||
@@ -805,7 +805,7 @@ func GetNumberOfChannelsOnTeam(teamId string) (int, *model.AppError) {
|
||||
func SetActiveChannel(userId string, channelId string) *model.AppError {
|
||||
status, err := GetStatus(userId)
|
||||
if err != nil {
|
||||
status = &model.Status{userId, model.STATUS_ONLINE, false, model.GetMillis(), channelId}
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: channelId}
|
||||
} else {
|
||||
status.ActiveChannel = channelId
|
||||
if !status.Manual {
|
||||
|
||||
@@ -513,7 +513,7 @@ func TestImportImportTeam(t *testing.T) {
|
||||
// Check that one more team is in the DB.
|
||||
if r := <-Srv.Store.Team().AnalyticsTeamCount(); r.Err == nil {
|
||||
if r.Data.(int64)-1 != teamsCount {
|
||||
t.Fatalf("Team did not get saved in apply run mode.", r.Data.(int64), teamsCount)
|
||||
t.Fatalf("Team did not get saved in apply run mode. analytics=%v teamcount=%v", r.Data.(int64), teamsCount)
|
||||
}
|
||||
} else {
|
||||
t.Fatalf("Failed to get team count.")
|
||||
@@ -542,7 +542,7 @@ func TestImportImportTeam(t *testing.T) {
|
||||
|
||||
if r := <-Srv.Store.Team().AnalyticsTeamCount(); r.Err == nil {
|
||||
if r.Data.(int64)-1 != teamsCount {
|
||||
t.Fatalf("Team alterations did not get saved in apply run mode.", r.Data.(int64), teamsCount)
|
||||
t.Fatalf("Team alterations did not get saved in apply run mode. analytics=%v teamcount=%v", r.Data.(int64), teamsCount)
|
||||
}
|
||||
} else {
|
||||
t.Fatalf("Failed to get team count.")
|
||||
|
||||
@@ -241,7 +241,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
|
||||
var status *model.Status
|
||||
var err *model.AppError
|
||||
if status, err = GetStatus(id); err != nil {
|
||||
status = &model.Status{id, model.STATUS_OFFLINE, false, 0, ""}
|
||||
status = &model.Status{UserId: id, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
if DoesStatusAllowPushNotification(profileMap[id], status, post.ChannelId) {
|
||||
@@ -254,7 +254,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
|
||||
var status *model.Status
|
||||
var err *model.AppError
|
||||
if status, err = GetStatus(id); err != nil {
|
||||
status = &model.Status{id, model.STATUS_OFFLINE, false, 0, ""}
|
||||
status = &model.Status{UserId: id, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
if DoesStatusAllowPushNotification(profileMap[id], status, post.ChannelId) {
|
||||
|
||||
@@ -100,7 +100,7 @@ func SetStatusOnline(userId string, sessionId string, manual bool) {
|
||||
var err *model.AppError
|
||||
|
||||
if status, err = GetStatus(userId); err != nil {
|
||||
status = &model.Status{userId, model.STATUS_ONLINE, false, model.GetMillis(), ""}
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
broadcast = true
|
||||
} else {
|
||||
if status.Manual && !manual {
|
||||
@@ -157,7 +157,7 @@ func SetStatusOffline(userId string, manual bool) {
|
||||
return // manually set status always overrides non-manual one
|
||||
}
|
||||
|
||||
status = &model.Status{userId, model.STATUS_OFFLINE, manual, model.GetMillis(), ""}
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: manual, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
|
||||
AddStatusCache(status)
|
||||
|
||||
@@ -175,7 +175,7 @@ func SetStatusAwayIfNeeded(userId string, manual bool) {
|
||||
status, err := GetStatus(userId)
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{userId, model.STATUS_OFFLINE, manual, 0, ""}
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: manual, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
if !manual && status.Manual {
|
||||
|
||||
@@ -307,11 +307,9 @@ func IsUsernameTaken(name string) bool {
|
||||
|
||||
if result := <-Srv.Store.User().GetByUsername(name); result.Err != nil {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func GetUser(userId string) (*model.User, *model.AppError) {
|
||||
|
||||
Ссылка в новой задаче
Block a user