type-fix-8

This commit is contained in:
Untone 2024-03-02 14:51:37 +03:00
parent 29026ed6fb
commit 4351f5cd32

View File

@ -219,6 +219,7 @@ func (c *provider) GetBoolStoreEnvVariable(key string) (bool, error) {
return data == "1", nil return data == "1", nil
} }
type AuthorProfile struct { type AuthorProfile struct {
ID int `json:"id"` ID int `json:"id"`
// Add other fields as necessary // Add other fields as necessary
@ -243,21 +244,20 @@ func (c *provider) GetUserAppDataFromRedis(userId string) (string, error) {
// Use authorProfileMap["id"] here if necessary // Use authorProfileMap["id"] here if necessary
authorId := int(authorProfileMap["id"].(float64)) // convert float64 to int authorId := int(authorProfileMap["id"].(float64)) // convert float64 to int
if authorId != nil { combinedData += fmt.Sprintf(`"profile": %s`, authorProfileString)
combinedData += fmt.Sprintf(`"profile": %s`, authorProfileString)
} authorFollowsAuthorsString := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:follows-authors`, authorId)).Val()
authorFollowsAuthorsString := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:follows-authors`, authorId)) if authorFollowsAuthorsString != "" {
if authorFollowsAuthorsString != nil {
combinedData += fmt.Sprintf(`,"authors": %s`, authorFollowsAuthorsString) combinedData += fmt.Sprintf(`,"authors": %s`, authorFollowsAuthorsString)
} }
authorFollowsTopicsString := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:follows-topics`, authorId)) authorFollowsTopicsString := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:follows-topics`, authorId)).Val()
if authorFollowsTopicsString != nil { if authorFollowsTopicsString != "" {
combinedData += fmt.Sprintf(`,"topics": %s`, authorFollowsTopicsString) combinedData += fmt.Sprintf(`,"topics": %s`, authorFollowsTopicsString)
} }
authorFollowers := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:followers`, authorId)) authorFollowers := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:followers`, authorId)).Val()
if authorFollowers != nil { if authorFollowers != "" {
combinedData += fmt.Sprintf(`,"followers": %s`, authorFollowers) combinedData += fmt.Sprintf(`,"followers": %s`, authorFollowers)
} }