1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat: option to publicly share stats data (resolve #36)

This commit is contained in:
Ferdinand Mütsch
2021-02-06 22:32:03 +01:00
parent d1dc73b5e6
commit fca12f522f
12 changed files with 605 additions and 414 deletions

View File

@@ -54,7 +54,20 @@ func (r *UserRepository) InsertOrGet(user *models.User) (*models.User, bool, err
}
func (r *UserRepository) Update(user *models.User) (*models.User, error) {
result := r.db.Model(user).Updates(user)
updateMap := map[string]interface{}{
"api_key": user.ApiKey,
"password": user.Password,
"last_logged_in_at": user.LastLoggedInAt,
"share_data_max_days": user.ShareDataMaxDays,
"share_editors": user.ShareEditors,
"share_languages": user.ShareLanguages,
"share_oss": user.ShareOSs,
"share_projects": user.ShareProjects,
"share_machines": user.ShareMachines,
"wakatime_api_key": user.WakatimeApiKey,
}
result := r.db.Model(user).Updates(updateMap)
if err := result.Error; err != nil {
return nil, err
}