decentraland / decentraland/unity-explorer

[Profiles] Unify Profiles retrieval in Social Service

Open
#6,179 5 comments 0 reactions 1 assignee Claimed by @mikhail-dcl View on GitHub
2-medium optimization stale
Dominant language
C#
Stars
23
Forks
17
Avg merge
2d 17h
Merged PRs (30d)
110

Description

Blocked by #5711 & #6177

## Problem

The majority of the endpoints in Social Service require fetching a profile/profiles and returning it to the client. It creates a dependency on the catalyst: the social service is centralized, but the catalyst is not, so it's an external call for the social services.

In order to reduce the performance implications on the backend side there is Redis cache:
- it should be maintained
- it becomes a new bottleneck as the whole profile is retrieved from the catalyst, and then written to the cache, while only the fraction of data needed
- the performance degrades with concurrency

It's a bad design from the client perspective as well:
- Profile-related structures are unique and are not unified with `ProfileRepository` that contains the cache
- Having no awareness of the client cache state create the unneeded pressure on the backend.

## Solution

- Remove custom profile-related information from the Social Service

### `getOwnerName: (ownerAddress: EthAddress, communityId?: string)`

`createCommunity`: `ownerAddress` is not used and can be deleted.
`getCommunity`: Mostly likely is already in the client’s cache. It’s better to remove it from the backend

### `getOwnersNames: (ownerAddresses: EthAddress[])`

Retrieved as part of `getCommunities` . Along with friends’ profiles, it can be resolved as a batch on the client side.

### `catalyst-client.getProfiles`

`getCommunities` : friends profiles. Resolve as a batch on the client side.
`getCommunityMembers` : the same

`getFriendsProfiles` : can return the array of ids, the rest can be resolved on the client side.

`getBlockedUsers` : leave `Timestamp` and `UserId` only, the rest can be resolved on the client.
`getMutualFriendsProfiles`: the same.
`getPendingFriendshipRequests`: the same.
`getSentFriendshipRequests` : the same.

- All APIs will return only information contained in the social service itself without interdependencies. It will be a `userId` complimented with some additional unique data.
- The client will resolve those Ids into the profiles via a batch `POST Profiles` `trimmed` version.
- The client will be able to cache it, and don't retrieve already cached profiles. It aims at reducing drastically the data transferred
- Change `FriendsService` and `CommunityDataProvider` to communicate with `IRealmProfileRepository` to retrieve all the required information before producing the resulting response => it will allow to minimize the flow changes.

## Backend ticket

TODO

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.