style: apply oxfmt to backend + docs
This commit is contained in:
@@ -29,9 +29,9 @@ export interface DirectoryEntry {
|
||||
}
|
||||
|
||||
export function getDirectoryRefreshedAt(): number | null {
|
||||
const row = db
|
||||
.prepare("SELECT refreshed_at FROM slack_directory_meta WHERE id = 1")
|
||||
.get() as { refreshed_at: number } | undefined
|
||||
const row = db.prepare("SELECT refreshed_at FROM slack_directory_meta WHERE id = 1").get() as
|
||||
| { refreshed_at: number }
|
||||
| undefined
|
||||
return row ? row.refreshed_at : null
|
||||
}
|
||||
|
||||
@@ -56,9 +56,11 @@ export function replaceDirectory(entries: DirectoryEntry[]): void {
|
||||
}
|
||||
|
||||
export function getDirectoryMap(): Map<string, DirectoryEntry> {
|
||||
const rows = db
|
||||
.prepare("SELECT email, image_url, slack_id FROM slack_directory")
|
||||
.all() as { email: string; image_url: string | null; slack_id: string }[]
|
||||
const rows = db.prepare("SELECT email, image_url, slack_id FROM slack_directory").all() as {
|
||||
email: string
|
||||
image_url: string | null
|
||||
slack_id: string
|
||||
}[]
|
||||
const map = new Map<string, DirectoryEntry>()
|
||||
for (const r of rows) {
|
||||
map.set(r.email, { email: r.email, imageUrl: r.image_url, slackId: r.slack_id })
|
||||
|
||||
@@ -10,12 +10,7 @@ export const fixtureProjects: Project[] = [
|
||||
{ id: "demo-zephyr", name: "Zephyr Mobile App", clientName: "Globex" },
|
||||
]
|
||||
|
||||
function member(
|
||||
id: string,
|
||||
firstName: string,
|
||||
lastName: string,
|
||||
role: string,
|
||||
): Member {
|
||||
function member(id: string, firstName: string, lastName: string, role: string): Member {
|
||||
return {
|
||||
id,
|
||||
firstName,
|
||||
|
||||
@@ -35,9 +35,7 @@ app.get("/api/projects/:id/members", async (c) => {
|
||||
return c.json({ source: "fixture", slack: "unconfigured", members: fixtureMembers(id) })
|
||||
}
|
||||
try {
|
||||
const { members, slack } = await enrichWithSlackAvatars(
|
||||
await fetchNaptaProjectMembers(id),
|
||||
)
|
||||
const { members, slack } = await enrichWithSlackAvatars(await fetchNaptaProjectMembers(id))
|
||||
return c.json({ source: "napta", slack, members })
|
||||
} catch (err) {
|
||||
console.error("fetchNaptaProjectMembers failed:", err)
|
||||
@@ -57,7 +55,5 @@ app.post("/api/slack/refresh", async (c) => {
|
||||
}
|
||||
})
|
||||
|
||||
console.log(
|
||||
`photofetch backend listening on :${config.port} (napta: ${hasNaptaCredentials})`,
|
||||
)
|
||||
console.log(`photofetch backend listening on :${config.port} (napta: ${hasNaptaCredentials})`)
|
||||
serve({ fetch: app.fetch, port: config.port })
|
||||
|
||||
@@ -65,11 +65,7 @@ interface QueryOpts {
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
async function naptaGetPage(
|
||||
path: string,
|
||||
opts: QueryOpts,
|
||||
page: number,
|
||||
): Promise<JsonApiResponse> {
|
||||
async function naptaGetPage(path: string, opts: QueryOpts, page: number): Promise<JsonApiResponse> {
|
||||
const token = await getAccessToken()
|
||||
const url = new URL(`${config.naptaBaseUrl}${path}`)
|
||||
// flask-rest-jsonapi: ?filter=[{"name","op","val"}], page[size], page[number], include.
|
||||
@@ -198,7 +194,6 @@ export async function fetchNaptaProjectMembers(projectId: string): Promise<Membe
|
||||
}
|
||||
|
||||
return [...byUserId.values()].sort(
|
||||
(a, b) =>
|
||||
a.lastName.localeCompare(b.lastName) || a.firstName.localeCompare(b.firstName),
|
||||
(a, b) => a.lastName.localeCompare(b.lastName) || a.firstName.localeCompare(b.firstName),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -52,8 +52,7 @@ export async function refreshDirectory(): Promise<number> {
|
||||
if (u.deleted || u.is_bot || u.id === "USLACKBOT") continue
|
||||
const email = u.profile?.email
|
||||
if (!email) continue
|
||||
const imageUrl =
|
||||
u.profile?.image_512 || u.profile?.image_192 || u.profile?.image_72 || null
|
||||
const imageUrl = u.profile?.image_512 || u.profile?.image_192 || u.profile?.image_72 || null
|
||||
entries.push({ email, imageUrl, slackId: u.id })
|
||||
}
|
||||
cursor = page.response_metadata?.next_cursor || undefined
|
||||
|
||||
Reference in New Issue
Block a user