PERF: Use a separate route for user cards, and split user serializer (#8789)

Adds a new route `/u/{username}/card.json`, which has a reduced number of fields. This change is behind a hidden site setting, so we can test compatibility before rolling out.
This commit is contained in:
David Taylor
2020-01-28 11:55:46 +00:00
committed by GitHub
parent c344f43211
commit 25fd2b544a
8 changed files with 281 additions and 209 deletions

View File

@@ -140,8 +140,11 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
this._positionCard($target);
this.setProperties({ visible: true, loading: true });
const args = { stats: false };
args.include_post_count_for = this.get("topic.id");
const args = {
forCard: this.siteSettings.enable_new_user_card_route,
include_post_count_for: this.get("topic.id")
};
User.findByUsername(username, args)
.then(user => {
if (user.topic_post_count) {

View File

@@ -536,7 +536,15 @@ const User = RestModel.extend({
const user = this;
return PreloadStore.getAndRemove(`user_${user.get("username")}`, () => {
return ajax(userPath(`${user.get("username")}.json`), { data: options });
const useCardRoute = options && options.forCard;
if (options) delete options.forCard;
const path = useCardRoute
? `${user.get("username")}/card.json`
: `${user.get("username")}.json`;
return ajax(userPath(path), { data: options });
}).then(json => {
if (!isEmpty(json.user.stats)) {
json.user.stats = User.groupStats(