Skip to content

Commit

Permalink
renamed isReadyTo... to checkIsReadyTo... services
Browse files Browse the repository at this point in the history
  • Loading branch information
Florin H committed Oct 11, 2023
1 parent 46d7670 commit 099171d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion api/src/components/coauthor/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ export const requestApproval = async (
}

if (version.currentStatus === 'DRAFT') {
const isReadyToRequestApprovals = await publicationVersionService.isReadyToRequestApproval(version);
const isReadyToRequestApprovals = await publicationVersionService.checkIsReadyToRequestApprovals(version);

if (!isReadyToRequestApprovals) {
return response.json(403, {
Expand Down
6 changes: 3 additions & 3 deletions api/src/components/publicationVersion/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const updateStatus = async (
}

// check if publication version is ready to be LOCKED
if (!(await publicationVersionService.isReadyToLock(publicationVersion))) {
if (!(await publicationVersionService.checkIsReadyToLock(publicationVersion))) {
return response.json(403, {
message: 'Publication is not ready to be LOCKED. Make sure all fields are filled in.'
});
Expand All @@ -191,7 +191,7 @@ export const updateStatus = async (
}

if (newStatus === 'LIVE') {
const isReadyToPublish = await publicationVersionService.isReadyToPublish(publicationVersion);
const isReadyToPublish = await publicationVersionService.checkIsReadyToPublish(publicationVersion);

if (!isReadyToPublish) {
return response.json(403, {
Expand All @@ -215,7 +215,7 @@ export const updateStatus = async (
}

if (newStatus === 'LIVE') {
const isReadyToPublish = await publicationVersionService.isReadyToPublish(publicationVersion);
const isReadyToPublish = await publicationVersionService.checkIsReadyToPublish(publicationVersion);

if (!isReadyToPublish) {
return response.json(403, {
Expand Down
15 changes: 6 additions & 9 deletions api/src/components/publicationVersion/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as client from 'lib/client';
import * as publicationService from 'publication/service';
import * as Helpers from 'lib/helpers';

export const getById = async (id: string) => {
const publicationVersion = client.prisma.publicationVersion.findFirst({
export const getById = (id: string) =>
client.prisma.publicationVersion.findFirst({
where: {
id
},
Expand Down Expand Up @@ -76,9 +76,6 @@ export const getById = async (id: string) => {
}
});

return publicationVersion;
};

export const get = (publicationId: string, version: string | number) =>
client.prisma.publicationVersion.findFirst({
where: {
Expand Down Expand Up @@ -274,7 +271,7 @@ export const validateConflictOfInterest = (version: I.PublicationVersion) => {
return true;
};

export const isReadyToPublish = async (publicationVersion: I.PublicationVersion): Promise<boolean> => {
export const checkIsReadyToPublish = async (publicationVersion: I.PublicationVersion): Promise<boolean> => {
if (!publicationVersion) {
return false;
}
Expand Down Expand Up @@ -310,7 +307,7 @@ export const isReadyToPublish = async (publicationVersion: I.PublicationVersion)
);
};

export const isReadyToRequestApproval = async (publicationVersion: I.PublicationVersion): Promise<boolean> => {
export const checkIsReadyToRequestApprovals = async (publicationVersion: I.PublicationVersion): Promise<boolean> => {
if (!publicationVersion) {
return false;
}
Expand Down Expand Up @@ -348,7 +345,7 @@ export const isReadyToRequestApproval = async (publicationVersion: I.Publication
);
};

export const isReadyToLock = async (publicationVersion: I.PublicationVersion): Promise<boolean> => {
export const checkIsReadyToLock = async (publicationVersion: I.PublicationVersion): Promise<boolean> => {
if (!publicationVersion) {
return false;
}
Expand All @@ -357,7 +354,7 @@ export const isReadyToLock = async (publicationVersion: I.PublicationVersion): P
return false;
}

const isReadyToRequestApprovals = await isReadyToRequestApproval(publicationVersion);
const isReadyToRequestApprovals = await checkIsReadyToRequestApprovals(publicationVersion);
const hasRequestedApprovals = !!publicationVersion.coAuthors.some((author) => author.approvalRequested);

return isReadyToRequestApprovals && hasRequestedApprovals;
Expand Down

0 comments on commit 099171d

Please sign in to comment.