Skip to content

Commit 53773ec

Browse files
committed
rfac: revert all backend changes
1 parent 3b2b92a commit 53773ec

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

backend/db/client.go

+30-28
Original file line numberDiff line numberDiff line change
@@ -357,23 +357,23 @@ func AddUserInfoToDb(username string, userId string, userAgent string, ip string
357357
}
358358

359359
func GetUserInfo(userId string) string {
360-
info, _ := redisClient.Get(ctx, fmt.Sprintf("info:%v", userId)).Result()
361-
var _info models.UserInfo
362-
err := json.Unmarshal([]byte(info), &_info)
363-
if err != nil {
360+
info, _ := redisClient.Get(ctx, fmt.Sprintf("info:%v", userId)).Result()
361+
var _info models.UserInfo
362+
err := json.Unmarshal([]byte(info), &_info)
363+
if(err != nil){
364364
logging.LogException(err)
365365
panic(err)
366366
}
367367
formattedInfo := fmt.Sprintf(
368-
"UserID: %s\nName: %s\nIP: %s\nLocation: %s\nOS: %s\nAgent: %s\nChatChannel: %s",
369-
_info.UserID,
370-
_info.Username,
371-
_info.IP,
372-
_info.Location,
373-
_info.OS,
374-
_info.Agent,
375-
_info.Channel,
376-
)
368+
"UserID: %s\nName: %s\nIP: %s\nLocation: %s\nOS: %s\nAgent: %s\nChatChannel: %s",
369+
_info.UserID,
370+
_info.Username,
371+
_info.IP,
372+
_info.Location,
373+
_info.OS,
374+
_info.Agent,
375+
_info.Channel,
376+
)
377377
return formattedInfo
378378
}
379379

@@ -423,6 +423,7 @@ func UpsertProject(project models.Project) {
423423
"projectAppStoreLink": string(project.AppStoreLink),
424424
"projectGithubLink": string(project.GithubLink),
425425
"projectPlayStoreLink": string(project.PlayStoreLink),
426+
426427
}).Result()
427428
if err != nil {
428429
logging.LogException(err)
@@ -447,32 +448,32 @@ func UpsertProject(project models.Project) {
447448
// return project
448449
// }
449450

450-
func GetAllProjects() ([]models.Project, error) {
451+
func GetAllProjects() ([]models.Project , error) {
451452
keys, err := redisClient.Keys(redisClient.Context(), "project:*").Result()
452453
if err != nil {
453454
logging.LogException(err)
454-
return nil, err
455+
return nil , err
455456
}
456457
var projects []models.Project
457458
for _, key := range keys {
458459
result, err := redisClient.HGetAll(redisClient.Context(), key).Result()
459460
if err != nil {
460461
logging.LogException(err)
461-
return nil, err
462+
return nil , err
462463
}
463464
project := models.Project{
464-
Name: key[len("project:"):],
465-
Category: models.ProjectCategory(result["projectCategory"]),
466-
ShortDesc: result["projectShortDescription"],
467-
LongDesc: result["projectLongDescription"],
468-
ImageLink: result["projectImageLink"],
469-
AppStoreLink: result["projectAppStoreLink"],
470-
GithubLink: result["projectGithubLink"],
465+
Name: key[len("project:"):],
466+
Category: models.ProjectCategory(result["projectCategory"]),
467+
ShortDesc: result["projectShortDescription"],
468+
LongDesc: result["projectLongDescription"],
469+
ImageLink: result["projectImageLink"],
470+
AppStoreLink: result["projectAppStoreLink"],
471+
GithubLink: result["projectGithubLink"],
471472
PlayStoreLink: result["projectPlayStoreLink"],
472473
}
473474
projects = append(projects, project)
474475
}
475-
return projects, nil
476+
return projects , nil
476477
}
477478

478479
func isValidProjectCategory(category models.ProjectCategory) bool {
@@ -485,29 +486,30 @@ func isValidProjectCategory(category models.ProjectCategory) bool {
485486
}
486487

487488
func DeleteProject(projectName string) string {
488-
489+
489490
if !projectExists(projectName) {
490491
err := fmt.Errorf("project %s does not exist", projectName)
491492
logging.LogException(err)
492493
return err.Error()
493494
}
494495

496+
495497
key := "project:" + projectName
496498
_, err := redisClient.Del(redisClient.Context(), key).Result()
497499
if err != nil {
498500
logging.LogException(err)
499501
return err.Error()
500502
}
501503

502-
return fmt.Sprintf("project %v deleted succesfully", projectName)
504+
return fmt.Sprintf("project %v deleted succesfully" , projectName)
503505
}
504506

505-
func projectExists(projectName string) bool {
507+
func projectExists( projectName string) bool {
506508
key := "project:" + projectName
507509
exists, err := redisClient.Exists(redisClient.Context(), key).Result()
508510
if err != nil {
509511
logging.LogException(err)
510512
return false
511513
}
512514
return exists == 1
513-
}
515+
}

0 commit comments

Comments
 (0)