Skip to content

Commit

Permalink
like counts on profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Sep 11, 2024
1 parent b120217 commit 44cad02
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 259 deletions.
7 changes: 7 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3104,6 +3104,7 @@ components:
- bio
- followers
- following
- like_score
- interests
- links
- meta
Expand All @@ -3122,6 +3123,8 @@ components:
$ref: "#/components/schemas/ProfileFollowersCount"
following:
$ref: "#/components/schemas/ProfileFollowingCount"
like_score:
$ref: "#/components/schemas/LikeScore"
interests:
$ref: "#/components/schemas/TagList"
links:
Expand Down Expand Up @@ -3676,6 +3679,10 @@ components:
be overkill. For use on minimal item reference schemas.
type: integer

LikeScore:
description: The total number of likes received by a member.
type: integer

LikeStatus:
description: |
A boolean indicating if the account in context has liked this item.
Expand Down
1 change: 1 addition & 0 deletions app/resources/account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Account struct {
Admin bool
Followers int
Following int
LikeScore int
Auths []string
EmailAddresses []*EmailAddress
VerifiedStatus VerifiedStatus
Expand Down
6 changes: 6 additions & 0 deletions app/resources/account/account_querier/account_querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,14 @@ func queryFollows(ctx context.Context, a *ent.Account, acc *account.Account) (*a
return nil, fault.Wrap(err, fctx.With(ctx))
}

likes, err := a.QueryPosts().QueryLikes().Count(ctx)
if err != nil {
return nil, fault.Wrap(err, fctx.With(ctx))
}

acc.Followers = followers
acc.Following = following
acc.LikeScore = likes

return acc, nil
}
2 changes: 2 additions & 0 deletions app/resources/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Public struct {
Admin bool
Followers int
Following int
LikeScore int
Interests []*tag.Tag
ExternalLinks []account.ExternalLink
Metadata map[string]any
Expand Down Expand Up @@ -77,6 +78,7 @@ func ProfileFromAccount(a *account.Account) *Public {
Admin: a.Admin,
Followers: a.Followers,
Following: a.Following,
LikeScore: a.LikeScore,
Interests: nil,
ExternalLinks: a.ExternalLinks,
Metadata: a.Metadata,
Expand Down
2 changes: 2 additions & 0 deletions app/transports/http/bindings/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func (p *Profiles) ProfileGet(ctx context.Context, request openapi.ProfileGetReq
Image: &avatarURL,
Followers: acc.Followers,
Following: acc.Following,
LikeScore: acc.LikeScore,
Name: acc.Name,
Links: serialiseExternalLinks(acc.ExternalLinks),
Meta: acc.Metadata,
Expand Down Expand Up @@ -249,6 +250,7 @@ func serialiseProfile(in *profile.Public) openapi.PublicProfile {
Name: in.Name,
Followers: in.Followers,
Following: in.Following,
LikeScore: in.LikeScore,
Links: serialiseExternalLinks(in.ExternalLinks),
Meta: in.Metadata,
}
Expand Down
524 changes: 265 additions & 259 deletions app/transports/http/openapi/server_gen.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/src/api/openapi-schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export * from "./likePostGetOKResponse";
export * from "./likeProfileGetOKResponse";
export * from "./likeProfileGetParams";
export * from "./likeProps";
export * from "./likeScore";
export * from "./likeStatus";
export * from "./link";
export * from "./linkCreateBody";
Expand Down
14 changes: 14 additions & 0 deletions web/src/api/openapi-schema/likeScore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Generated by orval v6.31.0 🍺
* Do not edit manually.
* storyden
* Storyden social API for building community driven platforms.
The Storyden API does not adhere to semantic versioning but instead applies a rolling strategy with deprecations and minimal breaking changes. This has been done mainly for a simpler development process and it may be changed to a more fixed versioning strategy in the future. Ultimately, the primary way Storyden tracks versions is dates, there are no set release tags currently.
* OpenAPI spec version: rolling
*/

/**
* The total number of likes received by a member.
*/
export type LikeScore = number;
2 changes: 2 additions & 0 deletions web/src/api/openapi-schema/publicProfileAllOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The Storyden API does not adhere to semantic versioning but instead applies a ro
import type { AccountBio } from "./accountBio";
import type { AccountHandle } from "./accountHandle";
import type { AccountName } from "./accountName";
import type { LikeScore } from "./likeScore";
import type { Metadata } from "./metadata";
import type { ProfileExternalLinkList } from "./profileExternalLinkList";
import type { ProfileFollowersCount } from "./profileFollowersCount";
Expand All @@ -24,6 +25,7 @@ export type PublicProfileAllOf = {
handle: AccountHandle;
image?: string;
interests: TagList;
like_score: LikeScore;
links: ProfileExternalLinkList;
meta: Metadata;
name: AccountName;
Expand Down

0 comments on commit 44cad02

Please sign in to comment.