feat: implemented getting user sources

This commit is contained in:
SoXX 2024-02-16 21:33:46 +01:00
parent 9a96e16e63
commit 02733498b9
3 changed files with 5 additions and 6 deletions

View File

@ -94,12 +94,12 @@ func GetUserFavoritesCount(ctx context.Context, driver neo4j.DriverWithContext,
return userFavoriteCount, nil
}
func GetUserWithRelationsAndSource(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error) {
func GetUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error) {
userSource := make(map[string]models.AnthroveUserRelationship)
query := `
MATCH (user:User{user_id: $anthrove_user_id})-[r:HAS_ACCOUNT_AT]->(s:Source)
MATCH (user:User{user_id: anthrove_user_id})-[r:HAS_ACCOUNT_AT]->(s:Source)
RETURN toString(r.user_id) AS sourceUserID, toString(r.username) AS sourceUsername, s.display_name as sourceDisplayName;
`
params := map[string]any{

View File

@ -44,7 +44,7 @@ type Graph interface {
GetUserFavoriteCount(ctx context.Context, anthroveUserID models.AnthroveUserID) (int64, error)
// GetUserSourceLinks retrieves the links between a user and sources in the graph
GetUserSourceLinks(ctx context.Context, anthroveUser *models.AnthroveUser) (map[string]models.AnthroveUserRelationship, error)
GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error)
// GetAnthroveUser retrieves an Anthrove user from the graph by their ID
GetAnthroveUser(ctx context.Context, anthroveUser *models.AnthroveUser) (*models.AnthroveUser, error)

View File

@ -80,9 +80,8 @@ func (g *graphConnection) GetUserFavoriteCount(ctx context.Context, anthroveUser
return internal.GetUserFavoritesCount(ctx, g.driver, anthroveUserID)
}
func (g *graphConnection) GetUserSourceLinks(ctx context.Context, anthroveUser *models.AnthroveUser) (map[string]models.AnthroveUserRelationship, error) {
//TODO implement me
panic("implement me")
func (g *graphConnection) GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error) {
return internal.GetUserSourceLink(ctx, g.driver, anthroveUserID)
}
func (g *graphConnection) GetAnthroveUser(ctx context.Context, anthroveUser *models.AnthroveUser) (*models.AnthroveUser, error) {