Skip to content

Commit

Permalink
Remove extra query param
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrel-b committed Dec 12, 2023
1 parent dbea1b5 commit b73030f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 56 deletions.
27 changes: 1 addition & 26 deletions db/gen/coredb/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -173350,7 +173350,7 @@
"insert_into_table": null
},
{
"text": "with sources as (\n select id from users where (traits-\u003e\u003e'top_activity')::bool\n union all select recommended_user_id from top_recommended_users\n union all select user_id from user_internal_recommendations\n union all select unnest($2::varchar[])\n), top_recs as (select sources.id from sources group by sources.id order by count(id) desc, random())\nselect users.id, users.deleted, users.version, users.last_updated, users.created_at, users.username, users.username_idempotent, users.wallets, users.bio, users.traits, users.universal, users.notification_settings, users.email_verified, users.email_unsubscriptions, users.featured_gallery, users.primary_wallet_id, users.user_experiences, users.profile_image_id from users join top_recs using(id) where not users.deleted and not users.universal limit $1",
"text": "with sources as (\n select id from users where (traits-\u003e\u003e'top_activity')::bool\n union all select recommended_user_id from top_recommended_users\n union all select user_id from user_internal_recommendations\n), top_recs as (select sources.id from sources group by sources.id order by count(id) desc, random())\nselect users.id, users.deleted, users.version, users.last_updated, users.created_at, users.username, users.username_idempotent, users.wallets, users.bio, users.traits, users.universal, users.notification_settings, users.email_verified, users.email_unsubscriptions, users.featured_gallery, users.primary_wallet_id, users.user_experiences, users.profile_image_id from users join top_recs using(id) where not users.deleted and not users.universal limit $1",
"name": "GetOnboardingUserRecommendations",
"cmd": ":many",
"columns": [
Expand Down Expand Up @@ -173848,31 +173848,6 @@
"unsigned": false,
"array_dims": 0
}
},
{
"number": 2,
"column": {
"name": "personalized_user_ids",
"not_null": true,
"is_array": true,
"comment": "",
"length": -1,
"is_named_param": false,
"is_func_call": false,
"scope": "",
"table": null,
"table_alias": "",
"type": {
"catalog": "",
"schema": "pg_catalog",
"name": "varchar"
},
"is_sqlc_slice": false,
"embed_table": null,
"original_name": "",
"unsigned": false,
"array_dims": 0
}
}
],
"comments": [],
Expand Down
10 changes: 2 additions & 8 deletions db/gen/coredb/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion db/queries/core/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,6 @@ with sources as (
select id from users where (traits->>'top_activity')::bool
union all select recommended_user_id from top_recommended_users
union all select user_id from user_internal_recommendations
union all select unnest(@personalized_user_ids::varchar[])
), top_recs as (select sources.id from sources group by sources.id order by count(id) desc, random())
select users.* from users join top_recs using(id) where not users.deleted and not users.universal limit $1;

Expand Down
23 changes: 2 additions & 21 deletions publicapi/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (api UserAPI) GetOnboardingUserRecommendations(ctx context.Context, before,
var err error

cache := newDBIDCache(api.cache, "onboarding_user_recommendations", 24*time.Hour, func(ctx context.Context) ([]persist.DBID, error) {
users, err = api.queries.GetOnboardingUserRecommendations(ctx, db.GetOnboardingUserRecommendationsParams{Limit: 100})
users, err = api.queries.GetOnboardingUserRecommendations(ctx, 100)
userIDs := util.MapWithoutError(users, func(u db.User) persist.DBID { return u.ID })
return userIDs, err
})
Expand Down Expand Up @@ -1375,28 +1375,9 @@ func (api UserAPI) GetExploreRecommendedUsers(ctx context.Context, before, after
return nil, PageInfo{}, err
}

users, err := api.queries.GetOnboardingUserRecommendations(ctx, db.GetOnboardingUserRecommendationsParams{
PersonalizedUserIds: util.MapWithoutError(userIDs, func(i persist.DBID) string { return i.String() }),
Limit: 100,
})
if err != nil {
return nil, PageInfo{}, err
}

userIDs = make([]persist.DBID, len(users))
positions := make(map[persist.DBID]int64, len(users))

for i, e := range users {
userIDs[i] = e.ID
positions[e.ID] = int64(i)
}

cursor := cursors.NewPositionCursor()
cursor.CurrentPosition = 0
cursor.IDs = userIDs
cursor.Positions = positions

paginator = api.paginatorFromResults(ctx, cursor, users)
cursor.Positions = sliceToMapIndex(userIDs)
}

paginator = api.paginatorFromCursor(ctx, cursor)
Expand Down

0 comments on commit b73030f

Please sign in to comment.