fixes stats
This commit is contained in:
@@ -117,7 +117,6 @@ export async function profile_stats_index(handle: string, filter: SummitLogFilte
|
|||||||
|
|
||||||
const r = await f(`/api/v1/profile/${handle}/stats?` + new URLSearchParams({
|
const r = await f(`/api/v1/profile/${handle}/stats?` + new URLSearchParams({
|
||||||
filter: filterText,
|
filter: filterText,
|
||||||
perPage: "-1",
|
|
||||||
expand: "trail.category,author",
|
expand: "trail.category,author",
|
||||||
sort: "+date",
|
sort: "+date",
|
||||||
}), {
|
}), {
|
||||||
@@ -129,8 +128,8 @@ export async function profile_stats_index(handle: string, filter: SummitLogFilte
|
|||||||
throw new APIError(r.status, response.message, response.detail)
|
throw new APIError(r.status, response.message, response.detail)
|
||||||
}
|
}
|
||||||
|
|
||||||
const result: ListResult<SummitLog> = await r.json();
|
const result: SummitLog[] = await r.json();
|
||||||
|
|
||||||
return result.items;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,10 +16,16 @@ export async function GET(event: RequestEvent) {
|
|||||||
const searchParams = Object.fromEntries(event.url.searchParams);
|
const searchParams = Object.fromEntries(event.url.searchParams);
|
||||||
const safeSearchParams = RecordListOptionsSchema.parse(searchParams);
|
const safeSearchParams = RecordListOptionsSchema.parse(searchParams);
|
||||||
|
|
||||||
let summitLogs: ListResult<SummitLog>;
|
if(safeSearchParams.filter?.length) {
|
||||||
|
safeSearchParams.filter = safeSearchParams.filter + `&&author='${actor.id}'`
|
||||||
|
}else {
|
||||||
|
safeSearchParams.filter = `author='${actor.id}'`
|
||||||
|
}
|
||||||
|
|
||||||
|
let summitLogs: SummitLog[];
|
||||||
if (actor.isLocal) {
|
if (actor.isLocal) {
|
||||||
summitLogs = await event.locals.pb.collection(Collection.summit_logs)
|
summitLogs = await event.locals.pb.collection(Collection.summit_logs)
|
||||||
.getList<SummitLog>(safeSearchParams.page, safeSearchParams.perPage, { ...safeSearchParams, filter: `author='${actor.id}'` })
|
.getFullList<SummitLog>(safeSearchParams.page, { ...safeSearchParams })
|
||||||
} else {
|
} else {
|
||||||
const origin = new URL(actor.iri).origin
|
const origin = new URL(actor.iri).origin
|
||||||
const summitLogURL = `${origin}/api/v1/profile/${actor.preferred_username}/stats?` + event.url.searchParams
|
const summitLogURL = `${origin}/api/v1/profile/${actor.preferred_username}/stats?` + event.url.searchParams
|
||||||
@@ -30,7 +36,7 @@ export async function GET(event: RequestEvent) {
|
|||||||
}
|
}
|
||||||
summitLogs = await response.json()
|
summitLogs = await response.json()
|
||||||
|
|
||||||
summitLogs.items.forEach(i => {
|
summitLogs.forEach(i => {
|
||||||
i.photos = i.photos.map(p =>
|
i.photos = i.photos.map(p =>
|
||||||
`${origin}/api/v1/files/summit_logs/${i.id}/${p}`
|
`${origin}/api/v1/files/summit_logs/${i.id}/${p}`
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user