type-fix-3
This commit is contained in:
parent
7a1df30325
commit
3a3407f85e
|
@ -219,7 +219,6 @@ 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
|
||||||
|
@ -233,27 +232,21 @@ func (c *provider) GetUserAppDataFromRedis(userId string) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse userProfileString into a UserProfile struct
|
// Parse authorProfileString into a map
|
||||||
var authorProfile AuthorProfile
|
var authorProfileMap map[string]interface{}
|
||||||
err = json.Unmarshal([]byte(authorProfileString), &authorProfile.ID)
|
err = json.Unmarshal([]byte(authorProfileString), &authorProfileMap)
|
||||||
if err != nil {
|
|
||||||
// If the ID is not a number, try unmarshalling it as a string instead
|
|
||||||
err = json.Unmarshal([]byte(authorProfileString), &authorProfile.ID)
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use userProfile.ID here if necessary
|
// Use authorProfileMap["id"] here if necessary
|
||||||
authorId := authorProfile.ID
|
authorId := int(authorProfileMap["id"].(float64)) // convert float64 to int
|
||||||
authorFollowsAuthorsString := c.store.Get(c.ctx, fmt.Sprintf(`author:%s:follows-authors`, authorId))
|
authorFollowsAuthorsString := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:follows-authors`, authorId))
|
||||||
authorFollowsTopicsString := c.store.Get(c.ctx, fmt.Sprintf(`author:%s:follows-topics`, authorId))
|
authorFollowsTopicsString := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:follows-topics`, authorId))
|
||||||
authorFollowers := c.store.Get(c.ctx, fmt.Sprintf(`author:%s:followers`, authorId))
|
authorFollowers := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:followers`, authorId))
|
||||||
|
|
||||||
// Combine user data into a JSON string
|
// Combine user data into a JSON string
|
||||||
combinedData := fmt.Sprintf(
|
combinedData := fmt.Sprintf(`{"profile": %s, "authors": %s, "topics": %s, "followers": %s}`,
|
||||||
`{"profile": %s, "authors": %s, "topics": %s, "followers": %s}`,
|
|
||||||
authorProfileString, authorFollowsAuthorsString, authorFollowsTopicsString, authorFollowers)
|
authorProfileString, authorFollowsAuthorsString, authorFollowsTopicsString, authorFollowers)
|
||||||
|
|
||||||
return combinedData, nil
|
return combinedData, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user