mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -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) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user