feat: the showcase is changed to sort by blog update time and only show characters that have blog updates in the last 15 days
This commit is contained in:
parent
6a0ba9c87f
commit
92f04875e7
|
|
@ -7,8 +7,8 @@
|
|||
51197, 32085, 1407, 51154, 51104, 40675, 4381, 43051, 50622, 51056, 33483, 19,
|
||||
50877, 33420, 50094, 49213, 33276, 50351, 42993, 50216, 50132, 50143, 43754,
|
||||
32168, 500, 47399, 33538, 48951, 33471, 33396, 37223, 33458, 39133, 20004,
|
||||
43625, 42787, 43258, 33462, 47109, 46939, 45701, 33233, 37346, 40671, 33870,
|
||||
33421, 51552, 51585, 48937, 51379, 51460, 51084, 51509, 51478, 51639, 48910,
|
||||
51139, 39329, 51683, 51077, 51374, 49120, 47356, 17096, 50708, 51430, 51935,
|
||||
51756, 6558, 49392, 52186, 52055, 52282, 52270, 5825, 51351, 52233
|
||||
43625, 42787, 43258, 33462, 47109, 46939, 45701, 33233, 37346, 40671, 51552,
|
||||
51585, 48937, 51379, 51460, 51084, 51509, 51478, 51639, 48910, 51139, 39329,
|
||||
51683, 51077, 51374, 49120, 47356, 17096, 50708, 51430, 51935, 51756, 6558,
|
||||
49392, 52186, 52055, 52282, 52270, 5825, 51351, 52233
|
||||
]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { createClient, cacheExchange, fetchExchange } from "@urql/core"
|
|||
import { Indexer } from "crossbell.js"
|
||||
import { CharacterOperatorPermission } from "crossbell.js"
|
||||
import type { useContract } from "@crossbell/contract"
|
||||
import dayjs from "dayjs"
|
||||
|
||||
type Contract = ReturnType<typeof useContract>
|
||||
|
||||
|
|
@ -135,22 +136,23 @@ export const getSites = async (input: number[]) => {
|
|||
url: "https://indexer.crossbell.io/v1/graphql",
|
||||
exchanges: [cacheExchange, fetchExchange],
|
||||
})
|
||||
const oneMonthAgo = dayjs().subtract(15, "day").toISOString()
|
||||
const result = await client
|
||||
.query(
|
||||
`
|
||||
query getCharacters($identities: [Int!], $limit: Int) {
|
||||
characters( where: { characterId: { in: $identities } }, orderBy: [{ updatedAt: desc }], take: $limit ) {
|
||||
handle
|
||||
updatedAt
|
||||
characterId
|
||||
notes {
|
||||
updatedAt
|
||||
}
|
||||
metadata {
|
||||
uri
|
||||
content
|
||||
}
|
||||
}
|
||||
notes( where: { characterId: { in: $identities }, createdAt: { gt: "${oneMonthAgo}" }, metadata: { is: { content: { path: "sources", array_contains: "xlog" } } } }, orderBy: [{ updatedAt: desc }] ) {
|
||||
characterId
|
||||
createdAt
|
||||
}
|
||||
}`,
|
||||
{
|
||||
identities: input,
|
||||
|
|
@ -171,18 +173,32 @@ export const getSites = async (input: number[]) => {
|
|||
site.metadata?.content?.attributes?.find(
|
||||
(a: any) => a.trait_type === "xlog_custom_domain",
|
||||
)?.value || ""
|
||||
|
||||
site.updatedAt = [...site.notes, site]
|
||||
.map((i) => i.updatedAt)
|
||||
.sort()
|
||||
.pop()
|
||||
})
|
||||
|
||||
result.data?.characters?.sort((a: any, b: any) => {
|
||||
return b.updatedAt > a.updatedAt ? 1 : -1
|
||||
const createdAts: {
|
||||
[key: string]: string
|
||||
} = {}
|
||||
result.data?.notes.forEach((note: any) => {
|
||||
if (!createdAts[note.characterId + ""]) {
|
||||
createdAts[note.characterId + ""] = note.createdAt
|
||||
}
|
||||
})
|
||||
const list = Object.keys(createdAts)
|
||||
.map((characterId: string) => {
|
||||
const character = result.data?.characters.find(
|
||||
(c: any) => c.characterId === characterId,
|
||||
)
|
||||
|
||||
return result.data?.characters
|
||||
return {
|
||||
...character,
|
||||
createdAt: createdAts[characterId],
|
||||
}
|
||||
})
|
||||
.sort((a: any, b: any) => {
|
||||
return b.createdAt > a.createdAt ? 1 : -1
|
||||
})
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
export const getSubscription = async (
|
||||
|
|
|
|||
Loading…
Reference in New Issue