Skip to content

Commit

Permalink
fix the daily star's empty name and avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
daoleno committed Dec 25, 2023
1 parent cbed4b2 commit bac7942
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions dashboard/app/api/analystics/getTopProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import "server-only"

import { ProfileFragment } from "@lens-protocol/client"

import { getLenny } from "@/lib/lenny"
import lensClient from "@/lib/lensclient"

import { DateRangeKey, getDateRangeCondition } from "./utils"

type TopProfile = ProfileFragment & { weighted_score: number }
type TopProfile = ProfileFragment & {
weighted_score: number
lenny_img: string
}

export async function getTopProfiles(rangeKey: DateRangeKey = "ALL") {
let baseSql = `
Expand Down Expand Up @@ -64,13 +68,17 @@ export async function getTopProfiles(rangeKey: DateRangeKey = "ALL") {
})

// add weighted score to profiles
const profiles = fetchResults.items.map((profile) => {
const profiles = []

for (let profile of fetchResults.items) {
const contributor = topProfiles.find((c) => c.profile_id === profile.id)
return {
const lennyImg = await getLenny(profile.id)
profiles.push({
...profile,
lenny_img: lennyImg.image,
weighted_score: Math.round(contributor?.weighted_score),
}
})
})
}

return profiles as TopProfile[]
}
4 changes: 2 additions & 2 deletions dashboard/components/top-profiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export default async function TopProfiles() {
backgroundImage: `url(${
profile.metadata?.picture
? getIPFSURL(profile.metadata.picture)
: null
: profile.lenny_img
})`,
}}
>
<span className="absolute bottom-0 m-2 inline-block rounded-full bg-muted px-2 py-1 text-sm font-bold text-muted-foreground">
{profile.metadata?.displayName}
{profile.metadata?.displayName || profile.handle?.localName}
</span>
</div>

Expand Down

0 comments on commit bac7942

Please sign in to comment.