Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(rm-children|2/?) remove most code related to pub children #995

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions core/actions/_lib/runActionInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { ClientException, ClientExceptionOptions } from "~/lib/serverAction
import { db } from "~/kysely/database";
import { hydratePubValues } from "~/lib/fields/utils";
import { createLastModifiedBy } from "~/lib/lastModifiedBy";
import { getPubsWithRelatedValuesAndChildren } from "~/lib/server";
import { getPubsWithRelatedValues } from "~/lib/server";
import { autoRevalidate } from "~/lib/server/cache/autoRevalidate";
import { isClientException } from "~/lib/serverActions";
import { getActionByName } from "../api";
Expand All @@ -40,7 +40,7 @@ const _runActionInstance = async (
): Promise<ActionInstanceRunResult> => {
const isActionUserInitiated = "userId" in args;

const pubPromise = getPubsWithRelatedValuesAndChildren(
const pubPromise = getPubsWithRelatedValues(
{
pubId: args.pubId,
communityId: args.communityId,
Expand Down
3 changes: 1 addition & 2 deletions core/actions/datacite/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ vitest.mock("~/lib/env/env.mjs", () => {

vitest.mock("~/lib/server", () => {
return {
getPubsWithRelatedValuesAndChildren: () => {
getPubsWithRelatedValues: () => {
return { ...pub, values: [] };
},
updatePub: vitest.fn(() => {
Expand Down Expand Up @@ -110,7 +110,6 @@ const pub = {
relatedPubId: null,
},
],
children: [],
communityId: "" as CommunitiesId,
createdAt: new Date(),
updatedAt: new Date(),
Expand Down
8 changes: 3 additions & 5 deletions core/actions/datacite/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ import type { ActionPub } from "../types";
import type { action } from "./action";
import type { components } from "./types";
import { env } from "~/lib/env/env.mjs";
import { getPubsWithRelatedValuesAndChildren, updatePub } from "~/lib/server";
import { getPubsWithRelatedValues, updatePub } from "~/lib/server";
import { isClientExceptionOptions } from "~/lib/serverActions";
import { defineRun } from "../types";

type ConfigSchema = z.infer<(typeof action)["config"]["schema"]>;
type Config = ConfigSchema & { pubFields: { [K in keyof ConfigSchema]?: string[] } };
type Payload = components["schemas"]["Doi"];

type RelatedPubs = Awaited<
ReturnType<typeof getPubsWithRelatedValuesAndChildren<{}>>
>[number]["values"];
type RelatedPubs = Awaited<ReturnType<typeof getPubsWithRelatedValues<{}>>>[number]["values"];

const encodeDataciteCredentials = (username: string, password: string) =>
Buffer.from(`${username}:${password}`).toString("base64");
Expand Down Expand Up @@ -65,7 +63,7 @@ const makeDatacitePayload = async (pub: ActionPub, config: Config): Promise<Payl
"The DataCite action is missing a publication date field override."
);

const { values } = await getPubsWithRelatedValuesAndChildren({
const { values } = await getPubsWithRelatedValues({
pubId: pub.id as PubsId,
communityId: pub.communityId,
});
Expand Down
4 changes: 2 additions & 2 deletions core/actions/email/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
RenderWithPubPub,
} from "~/lib/server/render/pub/renderWithPubUtils";
import { db } from "~/kysely/database";
import { getPubsWithRelatedValuesAndChildren } from "~/lib/server";
import { getPubsWithRelatedValues } from "~/lib/server";
import { getCommunitySlug } from "~/lib/server/cache/getCommunitySlug";
import * as Email from "~/lib/server/email";
import { renderMarkdownWithPub } from "~/lib/server/render/pub/renderMarkdownWithPub";
Expand All @@ -30,7 +30,7 @@ export const run = defineRun<typeof action>(async ({ pub, config, args, communit
// will redundantly load the child pub. Ideally we would lazily fetch and
// cache the parent pub while processing the email template.
if (parentId) {
parentPub = await getPubsWithRelatedValuesAndChildren(
parentPub = await getPubsWithRelatedValues(
{ pubId: parentId, communityId },
{
withPubType: true,
Expand Down
20 changes: 10 additions & 10 deletions core/app/api/v0/c/[communitySlug]/site/[...ts-rest]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
doesPubExist,
ForbiddenError,
fullTextSearch,
getPubsWithRelatedValuesAndChildren,
getPubsWithRelatedValues,
NotFoundError,
removeAllPubRelationsBySlugs,
removePubRelations,
Expand Down Expand Up @@ -253,7 +253,7 @@ const handler = createNextHandler(
},
});

const pub = await getPubsWithRelatedValuesAndChildren(
const pub = await getPubsWithRelatedValues(
{
pubId: params.pubId as PubsId,
communityId: community.id,
Expand All @@ -276,7 +276,7 @@ const handler = createNextHandler(

const { pubTypeId, stageId, ...rest } = query;

const pubs = await getPubsWithRelatedValuesAndChildren(
const pubs = await getPubsWithRelatedValues(
{
communityId: community.id,
pubTypeId,
Expand Down Expand Up @@ -361,7 +361,7 @@ const handler = createNextHandler(
};
}

const pub = await getPubsWithRelatedValuesAndChildren({
const pub = await getPubsWithRelatedValues({
pubId: params.pubId as PubsId,
communityId: community.id,
userId: user.id,
Expand Down Expand Up @@ -476,7 +476,7 @@ const handler = createNextHandler(
};
}

const pub = await getPubsWithRelatedValuesAndChildren({
const pub = await getPubsWithRelatedValues({
pubId: params.pubId as PubsId,
communityId: community.id,
userId: user.id,
Expand Down Expand Up @@ -524,7 +524,7 @@ const handler = createNextHandler(
};
}

const pub = await getPubsWithRelatedValuesAndChildren({
const pub = await getPubsWithRelatedValues({
pubId: params.pubId as PubsId,
communityId: community.id,
userId: user.id,
Expand Down Expand Up @@ -571,7 +571,7 @@ const handler = createNextHandler(
};
}

const pub = await getPubsWithRelatedValuesAndChildren({
const pub = await getPubsWithRelatedValues({
pubId: params.pubId as PubsId,
communityId: community.id,
userId: user.id,
Expand Down Expand Up @@ -716,10 +716,10 @@ const handler = createNextHandler(
);

export {
handler as DELETE,
handler as GET,
handler as OPTIONS,
handler as PATCH,
handler as POST,
handler as PUT,
handler as PATCH,
handler as DELETE,
handler as OPTIONS,
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { getLoginData } from "~/lib/authentication/loginData";
import { getCommunityRole } from "~/lib/authentication/roles";
import { findCommunityBySlug } from "~/lib/server/community";
import { getForm, userHasPermissionToForm } from "~/lib/server/form";
import { getPubsWithRelatedValuesAndChildren } from "~/lib/server/pub";
import { getPubsWithRelatedValues } from "~/lib/server/pub";
import { getPubTypesForCommunity } from "~/lib/server/pubtype";
import { capitalize } from "~/lib/string";
import { ExternalFormWrapper } from "./ExternalFormWrapper";
Expand Down Expand Up @@ -142,12 +142,12 @@ export default async function FormPage(props: {
communityId: community.id,
}).executeTakeFirst(),
searchParams.pubId
? await getPubsWithRelatedValuesAndChildren(
? await getPubsWithRelatedValues(
{ pubId: searchParams.pubId, communityId: community.id },
{ withStage: true, withLegacyAssignee: true, withPubType: true }
)
: undefined,
getPubsWithRelatedValuesAndChildren(
getPubsWithRelatedValues(
{ communityId: community.id, userId: user?.id },
{
limit: 30,
Expand Down Expand Up @@ -203,7 +203,7 @@ export default async function FormPage(props: {
}

const parentPub = pub?.parentId
? await getPubsWithRelatedValuesAndChildren(
? await getPubsWithRelatedValues(
{ pubId: pub.parentId, communityId: community.id },
{ withStage: true, withLegacyAssignee: true, withPubType: true }
)
Expand Down
4 changes: 2 additions & 2 deletions core/app/c/[communitySlug]/pubs/PubList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cn } from "utils";

import { BasicPagination } from "~/app/components/Pagination";
import PubRow, { PubRowSkeleton } from "~/app/components/PubRow";
import { getPubsCount, getPubsWithRelatedValuesAndChildren } from "~/lib/server";
import { getPubsCount, getPubsWithRelatedValues } from "~/lib/server";
import { getCommunitySlug } from "~/lib/server/cache/getCommunitySlug";

const PAGE_SIZE = 10;
Expand All @@ -26,7 +26,7 @@ type PaginatedPubListProps = {
const PaginatedPubListInner = async (props: PaginatedPubListProps) => {
const [count, pubs] = await Promise.all([
getPubsCount({ communityId: props.communityId }),
getPubsWithRelatedValuesAndChildren(
getPubsWithRelatedValues(
{ communityId: props.communityId, userId: props.userId },
{
limit: PAGE_SIZE,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ import { DataTableColumnHeader } from "ui/data-table";
import type { FullProcessedPub } from "~/lib/server/pub";
import { DataTable } from "~/app/components/DataTable/DataTable";
import { getPubTitle } from "~/lib/pubs";
import { createdAtDateOptions } from "./getPubChildrenTableColumns";

export const createdAtDateOptions = {
month: "short",
day: "numeric",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
} satisfies Intl.DateTimeFormatOptions;

const getRelatedPubsColumns = () => {
return [
Expand Down
Loading
Loading