Skip to content

Commit

Permalink
Merge pull request #742 from JiscSD/OC-978
Browse files Browse the repository at this point in the history
OC-978: Add new flag categories
  • Loading branch information
finlay-jisc authored Dec 18, 2024
2 parents a61d225 + 5a5d247 commit 06c5714
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 18 deletions.
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'
| '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

0 comments on commit 06c5714

Please sign in to comment.