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

OC-978: Add new flag categories #742

Merged
merged 1 commit into from
Dec 18, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- AlterEnum
-- This migration adds more than one value to an enum.
-- With PostgreSQL versions 11 and earlier, this is not possible
-- in a single migration. This can be worked around by creating
-- multiple migrations, each migration adding only one value to
-- the enum.


ALTER TYPE "PublicationFlagCategoryEnum" ADD VALUE 'UNDECLARED_AI';
ALTER TYPE "PublicationFlagCategoryEnum" ADD VALUE 'NOT_IN_OCTOPUS_FORMAT';
ALTER TYPE "PublicationFlagCategoryEnum" ADD VALUE 'IRRELEVANT_LINKED_PUBLICATION';
3 changes: 3 additions & 0 deletions api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ enum PublicationFlagCategoryEnum {
UNDECLARED_IMAGE_MANIPULATION
COPYRIGHT
INAPPROPRIATE
UNDECLARED_AI
NOT_IN_OCTOPUS_FORMAT
IRRELEVANT_LINKED_PUBLICATION
}

enum LicenceType {
Expand Down
20 changes: 13 additions & 7 deletions api/src/components/flag/controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as cheerio from 'cheerio';
import nodemailer from 'nodemailer';

import * as email from 'lib/email';
import * as flagService from 'flag/service';
import * as Helpers from 'lib/helpers';
import * as response from 'lib/response';
import * as I from 'interface';
import * as publicationService from 'publication/service';
import * as flagService from 'flag/service';
import * as response from 'lib/response';
import * as userService from 'user/service';
import * as I from 'interface';
import * as email from 'lib/email';

export const get = async (event: I.APIRequest<undefined, undefined, I.GetFlagByID>): Promise<I.JSONResponse> => {
try {
Expand Down Expand Up @@ -48,14 +49,19 @@ export const getUserFlags = async (
}
};

const formatFlagType = (flagType: I.FlagCategory): string => {
const types = {
const formatFlagType = (flagType: I.PublicationFlagCategoryEnum): string => {
const types: {
[key in I.PublicationFlagCategoryEnum]: string;
} = {
PLAGIARISM: 'Plagiarism',
ETHICAL_ISSUES: 'Ethical issues',
MISREPRESENTATION: 'Misrepresentation',
UNDECLARED_IMAGE_MANIPULATION: 'Undeclared image manipulation',
COPYRIGHT: 'Copyright',
INAPPROPRIATE: 'Inappropriate'
INAPPROPRIATE: 'Inappropriate',
UNDECLARED_AI: 'Undeclared use of generative AI',
NOT_IN_OCTOPUS_FORMAT: 'Not in Octopus format',
IRRELEVANT_LINKED_PUBLICATION: 'Linked to irrelevant publication'
};

return types[flagType];
Expand Down
7 changes: 5 additions & 2 deletions api/src/components/flag/schema/createFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ const updatedPublicationSchema: I.Schema = {
properties: {
category: {
type: 'string',
enum: <I.FlagCategory[]>[
enum: <I.PublicationFlagCategoryEnum[]>[
'PLAGIARISM',
'ETHICAL_ISSUES',
'MISREPRESENTATION',
'UNDECLARED_IMAGE_MANIPULATION',
'COPYRIGHT',
'INAPPROPRIATE'
'INAPPROPRIATE',
'UNDECLARED_AI',
'NOT_IN_OCTOPUS_FORMAT',
'IRRELEVANT_LINKED_PUBLICATION'
]
},
comment: {
Expand Down
8 changes: 0 additions & 8 deletions api/src/lib/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,6 @@ export interface ConfirmVerificationCodeBody {
const prismaGeneratedFlagType = Prisma.validator<Prisma.PublicationFlagsDefaultArgs>()({});
export type Flag = Prisma.PublicationFlagsGetPayload<typeof prismaGeneratedFlagType>;

export type FlagCategory =
| 'PLAGIARISM'
finlay-jisc marked this conversation as resolved.
Show resolved Hide resolved
| 'ETHICAL_ISSUES'
| 'MISREPRESENTATION'
| 'UNDECLARED_IMAGE_MANIPULATION'
| 'COPYRIGHT'
| 'INAPPROPRIATE';

export interface CreateFlagPathParams {
publicationId: string;
}
Expand Down
12 changes: 12 additions & 0 deletions ui/src/config/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,18 @@ export const octopusInformation: Interfaces.OctopusInformation = {
INAPPROPRIATE: {
value: 'INAPPROPRIATE',
nicename: 'Inappropriate'
},
UNDECLARED_AI: {
value: 'UNDECLARED_AI',
nicename: 'Undeclared use of generative AI'
},
NOT_IN_OCTOPUS_FORMAT: {
value: 'NOT_IN_OCTOPUS_FORMAT',
nicename: 'Not in Octopus format'
},
IRRELEVANT_LINKED_PUBLICATION: {
value: 'IRRELEVANT_LINKED_PUBLICATION',
nicename: 'Linked to irrelevant publication'
}
}
};
Expand Down
5 changes: 4 additions & 1 deletion ui/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ export type RedFlagTypes =
| 'MISREPRESENTATION'
| 'UNDECLARED_IMAGE_MANIPULATION'
| 'COPYRIGHT'
| 'INAPPROPRIATE';
| 'INAPPROPRIATE'
| 'UNDECLARED_AI'
| 'NOT_IN_OCTOPUS_FORMAT'
| 'IRRELEVANT_LINKED_PUBLICATION';

export type Languages =
| 'ab'
Expand Down
Loading