Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions precomputer/src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PromisePool } from '@supercharge/promise-pool'
import { getClusterIndex } from './tasks/cluster-index.ts'
import { getClusterPackage } from './tasks/cluster.ts'
import { getFinalReviewIndex } from './tasks/final-review-index.ts'
import { getQueue } from './tasks/queue.ts'
import { getQueueIndex } from './tasks/queue-index.ts'
import { getApiClient } from './utils/api.ts'
import { CLUSTER_INDEX_PATH, clusterPathBuilder, deleteFromS3, FINAL_REVIEW_INDEX_PATH, listS3Files, QUEUE_INDEX_PATH, saveToS3 } from './utils/s3.ts'
import { type ClusterPackageCommon } from '../../website/app/utils/validators.ts'
Expand All @@ -19,8 +19,8 @@ const NUMBER_OF_CONCURRENT_S3_USAGES = 4

const main = async (): Promise<void> => {
const api = getApiClient()
const [queueCommon, clusterIndex, finalReviewIndex] = await Promise.all([
getQueue({ api }),
const [queueIndex, clusterIndex, finalReviewIndex] = await Promise.all([
getQueueIndex({ api }),
getClusterIndex({ api }),
getFinalReviewIndex({ api })
])
Expand Down Expand Up @@ -50,7 +50,7 @@ const main = async (): Promise<void> => {
console.log(`[Clusters] Successfully fetched ALL cluster API data for ${clusterPackages.length} cluster(s).`)

const uploadTasks: S3UploadTask[] = [
{ key: QUEUE_INDEX_PATH, contents: JSON.stringify(queueCommon) },
{ key: QUEUE_INDEX_PATH, contents: JSON.stringify(queueIndex) },
{ key: CLUSTER_INDEX_PATH, contents: JSON.stringify(clusterIndex) },
{ key: FINAL_REVIEW_INDEX_PATH, contents: JSON.stringify(finalReviewIndex) },
...clusterPackages.map((clusterPackage): S3UploadTask => {
Expand Down
2 changes: 2 additions & 0 deletions precomputer/src/tasks/cluster-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { PurpleApi } from "../../generated/purple_client/index.ts";
import { type ClusterIndexCommon, type ClusterItemCommon, ClusterIndexCommonSchema } from '../../../website/app/utils/validators.ts'
import { clusterMemberToClusterDocumentCommon } from "../utils/converters.ts";
import { DateTime } from "luxon";

type Props = {
api: PurpleApi
Expand All @@ -11,6 +12,7 @@ export const getClusterIndex = async ({ api }: Props): Promise<ClusterIndexCommo
const clusterList = await api.apiPubqClustersList()

const clusterIndexCommon: ClusterIndexCommon = {
generatedAtIso: DateTime.now().toISO(),
list: clusterList.filter(item => item.isActive).map((cluster): ClusterItemCommon => {
const { number, documents } = cluster
const clusterItems = documents?.map((clusterMember) => clusterMemberToClusterDocumentCommon(number, clusterMember)) ?? []
Expand Down
2 changes: 2 additions & 0 deletions precomputer/src/tasks/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { PurpleApi } from "../../generated/purple_client/index.ts";
import { type ClusterPackageCommon, ClusterPackageCommonSchema } from '../../../website/app/utils/validators.ts'
import { clusterMemberToClusterDocumentCommon } from "../utils/converters.ts";
import { DateTime } from "luxon";

type Props = {
api: PurpleApi
Expand All @@ -19,6 +20,7 @@ export const getClusterPackage = async ({ api, clusterNumber }: Props): Promise<
const clusterDocuments = cluster.documents?.map(clusterMember => clusterMemberToClusterDocumentCommon(cluster.number, clusterMember)) ?? []

const clusterPackage: ClusterPackageCommon = {
generatedAtIso: DateTime.now().toISO(),
cluster: {
number: cluster.number,
allPublished: clusterDocuments.length > 0 ? clusterDocuments.every(document => document.disposition === 'published') : false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ type Props = {
api: PurpleApi
}

export const getQueue = async (props: Props): Promise<QueueCommon> => getQueueCommon(props)
export const getQueueIndex = async (props: Props): Promise<QueueCommon> => getQueueCommon(props)
4 changes: 2 additions & 2 deletions precomputer/src/utils/dev-api-server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Fastify from 'fastify'
import { getApiClient } from './api.ts'
import { getQueue } from '../tasks/queue.ts'
import { getQueueIndex } from '../tasks/queue-index.ts'
import { getClusterPackage } from '../tasks/cluster.ts'
import { getClusterIndex } from '../tasks/cluster-index.ts'
import { getFinalReviewIndex } from '../tasks/final-review-index.ts'
Expand All @@ -11,7 +11,7 @@ const fastify = Fastify({

fastify.get('/api/v1/queue.json', async () => {
const api = getApiClient('dev')
const queueCommon = await getQueue({ api })
const queueCommon = await getQueueIndex({ api })
return queueCommon
})

Expand Down
2 changes: 2 additions & 0 deletions precomputer/src/utils/queue.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DateTime } from 'luxon'
import { PurpleApi, type ApiPubqQueueListRequest } from "../../generated/purple_client/index.ts";
import { type QueueCommon, type QueueCommonItem, QueueCommonSchema, type BlockingReason } from '../../../website/app/utils/validators.ts'
import { assertIsString } from "../utils/typescript.ts";
Expand All @@ -15,6 +16,7 @@ export const getQueueCommon = async ({ api, params }: Props): Promise<QueueCommo
const list = await api.apiPubqQueueList(params)

const queueCommon: QueueCommon = {
generatedAtIso: DateTime.now().toISO(),
items: list.map((queueItem): QueueCommonItem => {
const {
name,
Expand Down
2 changes: 1 addition & 1 deletion website/app/components/ClusterPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { data: clusterPackage, error, status } = await useAsyncData(
() => `cluster-${props.clusterNumber}`,
() => getClusterPackage(url.hostname, props.clusterNumber),
{
server: false,
server: true, // rendering on the server to generate real 404s for missing content
lazy: true,
}
)
Expand Down
18 changes: 13 additions & 5 deletions website/app/components/ClustersIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
</tr>
</RpcTfoot>
</RpcTable>
<p v-if="generatedAt" class="text-sm italic text-gray-600 dark:text-gray-400 mt-1">
Updated
<TimeStamp :dateTime="generatedAt" />
</p>
</div>
</template>

Expand All @@ -45,11 +49,10 @@ import {
getSortedRowModel,
} from '@tanstack/vue-table'
import { getVNodeText } from '../utils/vue'
import { DateTime } from 'luxon'

const url = useRequestURL()

const emptyArray: ClusterItemCommon[] = []

const {
data,
status,
Expand All @@ -59,11 +62,12 @@ const {
() => getClusterIndex(url.hostname),
{
server: false,
lazy: true,
default: () => emptyArray
lazy: true
}
)

const generatedAt = computed(() => data.value?.generatedAtIso ? DateTime.fromISO(data.value.generatedAtIso) : undefined)

const columnHelper = createColumnHelper<ClusterItemCommon>()

const sorting = ref<SortingState>([])
Expand Down Expand Up @@ -96,8 +100,12 @@ const columns = [
}),
]

const emptyArray: ClusterItemCommon[] = []

const table = useVueTable({
data,
get data() {
return data.value?.list ?? emptyArray // Need a const emptyArray rather than a new array every data(){} to prevent unnecessary rerenders / freezing
},
columns,
state: {
get sorting() {
Expand Down
11 changes: 6 additions & 5 deletions website/app/components/FinalReviewIndexTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ import { getFinalReviewIndex } from '~/utils/api'
import Label from './Label.vue'
import { finalReviewPathBuilder } from '~/utils/url'

const emptyArray: QueueCommonItem[] = []

const url = useRequestURL()

const {
Expand All @@ -62,8 +60,7 @@ const {
() => getFinalReviewIndex(url.hostname),
{
server: false,
lazy: true,
default: () => emptyArray
lazy: true
}
)

Expand Down Expand Up @@ -95,8 +92,12 @@ const columns = [
}),
]

const emptyArray: QueueCommonItem[] = []

const table = useVueTable({
data,
get data() {
return data.value?.items ?? emptyArray // Need a const emptyArray rather than a new array every data(){} to prevent unnecessary rerenders / freezing
},
columns,
state: {
get globalFilter() {
Expand Down
14 changes: 11 additions & 3 deletions website/app/components/FinalReviewPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@
class="flex flex-col gap-2">
<li v-for="approvalLog in finalReview.renderableApprovalLogMessages">
<component :is="approvalLog.logMessageComponent" />
<p class="text-sm italic text-gray-600 dark:text-gray-400 mt-1">Posted <TimeStamp :dateTime="approvalLog.time" /></p>
<p class="text-xs italic text-gray-600 dark:text-gray-400 mt-1">Posted
<TimeStamp :dateTime="approvalLog.time" />
</p>
</li>
</ol>
<p v-else class="italic">No logs available</p>

<p v-if="finalReview.generatedAt" class="text-sm italic text-gray-600 dark:text-gray-400 mt-1">
Updated
<TimeStamp :dateTime="finalReview.generatedAt" />
</p>
</template>
<template v-else>
<p>404: No final review found.</p>
Expand Down Expand Up @@ -45,17 +52,18 @@ const {
'final-review-index',
() => getFinalReviewIndex(url.hostname),
{
server: true,
server: true, // rendering on the server to generate real 404s for missing content
lazy: false,
}
)

const finalReview = computed(() => {
if (!data.value) return null
const item = data.value.find(queueCommonItem => queueCommonItem.name === props.draftName)
const item = data.value.items.find(queueCommonItem => queueCommonItem.name === props.draftName)
if (!item) return null
return {
...item,
generatedAt: data.value.generatedAtIso ? DateTime.fromISO(data.value.generatedAtIso) : undefined,
renderableApprovalLogMessages: item?.approvalLogMessages?.map(approvalLogMessage => {
const time = approvalLogMessage.timeIso ? DateTime.fromISO(approvalLogMessage.timeIso) : undefined
const timeAgo = time ? time.toRelativeCalendar() : undefined
Expand Down
18 changes: 12 additions & 6 deletions website/app/components/QueueIndexTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
</tr>
</RpcTfoot>
</RpcTable>
<p v-if="generatedAt" class="text-sm italic text-gray-600 dark:text-gray-400 mt-1">
Updated
<TimeStamp :dateTime="generatedAt" />
</p>
</div>
</template>

Expand Down Expand Up @@ -60,8 +64,6 @@ const url = useRequestURL()

const props = defineProps<Props>()

const emptyArray: QueueCommonItem[] = []

const {
data,
status,
Expand All @@ -71,11 +73,12 @@ const {
() => getQueueIndex(url.hostname),
{
server: false,
lazy: true,
default: () => emptyArray
lazy: true
}
)

const generatedAt = computed(() => data.value?.generatedAtIso ? DateTime.fromISO(data.value.generatedAtIso) : undefined)

const columnHelper = createColumnHelper<QueueCommonItem>()

const sorting = ref<SortingState>([])
Expand Down Expand Up @@ -224,11 +227,14 @@ const columns = [
return a - b
},
}),

]

const emptyArray: QueueCommonItem[] = []

const table = useVueTable({
data,
get data() {
return data.value?.items ?? emptyArray // Need a const emptyArray rather than a new array every data(){} to prevent unnecessary rerenders / freezing
},
columns,
state: {
get globalFilter() {
Expand Down
6 changes: 3 additions & 3 deletions website/app/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getQueueIndex = async (hostName: string) => {
console.error('Queue fetch succeeded but data failed validation', path, unverifiedData, error)
throw Error('Queue fetch failed. Try again later.')
}
return data.items
return data
}

export const getFinalReviewIndex = async (hostName: string) => {
Expand All @@ -22,7 +22,7 @@ export const getFinalReviewIndex = async (hostName: string) => {
console.error('Final review index fetch succeeded but data failed validation', path, unverifiedData, error)
throw Error('Final review index fetch failed. Try again later.')
}
return data.items
return data
}

export const getClusterIndex = async (hostName:string) => {
Expand All @@ -34,7 +34,7 @@ export const getClusterIndex = async (hostName:string) => {
console.error('Cluster index fetch succeeded but data failed validation', path, unverifiedData, error)
throw Error('Cluster index fetch failed. Try again later.')
}
return data.list
return data
}

export const getClusterPackage = async (hostName: string, clusterNumber: number) => {
Expand Down
3 changes: 3 additions & 0 deletions website/app/utils/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const QueueCommonItemSchema = z.object({
export type QueueCommonItem = z.infer<typeof QueueCommonItemSchema>

export const QueueCommonSchema = z.object({
generatedAtIso: z.string(),
items: z.array(QueueCommonItemSchema)
})

Expand Down Expand Up @@ -154,12 +155,14 @@ const ClusterRfcToBeCommonSchema = z.object({
export type ClusterRfcToBeCommon = z.infer<typeof ClusterRfcToBeCommonSchema>

export const ClusterPackageCommonSchema = z.object({
generatedAtIso: z.string(),
cluster: ClusterItemCommonSchema
})

export type ClusterPackageCommon = z.infer<typeof ClusterPackageCommonSchema>

export const ClusterIndexCommonSchema = z.object({
generatedAtIso: z.string(),
list: ClusterItemCommonSchema.array()
})

Expand Down