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

SCKAN-151 feat: Replace PMID with the sentence/statement ID #143

Merged
merged 1 commit into from
Sep 11, 2023
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
4 changes: 2 additions & 2 deletions backend/composer/api/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SentenceFilter(django_filters.FilterSet):
)
ordering = django_filters.OrderingFilter(
fields=(
("pmid", "pmid"),
("id", "id"),
("modified_date", "last_edited"),
),
)
Expand Down Expand Up @@ -78,7 +78,7 @@ class ConnectivityStatementFilter(django_filters.FilterSet):
)
ordering = django_filters.OrderingFilter(
fields=(
("sentence__pmid", "pmid"),
("id", "id"),
("modified_date", "last_edited"),
),
)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/apiclient/backend/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2.1
6.3.0
48 changes: 29 additions & 19 deletions frontend/src/apiclient/backend/api.ts

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions frontend/src/apiclient/backend/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
*/


import { Configuration } from "./configuration";
import type { Configuration } from './configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import globalAxios from 'axios';

export const BASE_PATH = "http://localhost".replace(/\/+$/, "");

Expand Down Expand Up @@ -64,8 +65,8 @@ export class BaseAPI {
* @extends {Error}
*/
export class RequiredError extends Error {
name: "RequiredError" = "RequiredError";
constructor(public field: string, msg?: string) {
super(msg);
this.name = "RequiredError"
}
}
8 changes: 5 additions & 3 deletions frontend/src/apiclient/backend/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
*/


import { Configuration } from "./configuration";
import { RequiredError, RequestArgs } from "./base";
import { AxiosInstance, AxiosResponse } from 'axios';
import type { Configuration } from "./configuration";
import type { RequestArgs } from "./base";
import type { AxiosInstance, AxiosResponse } from 'axios';
import { RequiredError } from "./base";

/**
*
Expand Down Expand Up @@ -84,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope
}

function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
if (parameter == null) return;
if (typeof parameter === "object") {
if (Array.isArray(parameter)) {
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import AutoComplete from "../AutoComplete";


type criteria =
| ("pmid" | "-pmid")[]
| ("id" | "-id")[]
| undefined;

export default function CheckDuplicates() {
Expand Down Expand Up @@ -71,10 +71,10 @@ export default function CheckDuplicates() {
} else {
const {field, sort} = model[0];
const sortingCriteria = `${field} ${sort}`;
if (sortingCriteria === "pmid asc") {
ordering = ["pmid"];
} else if (sortingCriteria === "pmid desc") {
ordering = ["-pmid"];
if (sortingCriteria === "id asc") {
ordering = ["id"];
} else if (sortingCriteria === "id desc") {
ordering = ["-id"];
}
}
fetchDuplicates(ordering);
Expand Down Expand Up @@ -103,7 +103,6 @@ export default function CheckDuplicates() {
const {id, sentence, knowledge_statement, state} = statement;
return {
id,
pmid: sentence.pmid,
knowledge_statement,
state,
};
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/CheckForDuplicates/ResultsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Typography from "@mui/material/Typography";
import { duplicatesRowsPerPage } from "../../helpers/settings";
import CustomPagination from "../CustomPagination";
import {
renderPMID,
renderID,
renderStatementState,
renderTitle,
} from "../DataGridWidgets/DataGridWidgets";
Expand All @@ -19,10 +19,10 @@ export default function ResultsGrid({
}: any) {
const columns: GridColDef[] = [
{
field: "pmid",
headerName: "PMID",
field: "id",
headerName: "ID",
headerClassName: "grid--header",
renderCell: renderPMID,
renderCell: renderID,
},
{
field: "state",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Tag from "../Widgets/Tag"
import {SentenceStateChip, StatementStateChip} from "../Widgets/StateChip"
import { Tooltip } from "@mui/material"

export const renderPMID = (params: GridRenderCellParams) => (
export const renderID = (params: GridRenderCellParams) => (
<Typography variant="subtitle1" color={vars.darkTextColor}>
{params.value}
</Typography>
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/components/EntityDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ConnectivityStatement, Sentence, Tag } from "../apiclient/backend";
import {
renderDate,
renderNote,
renderPMID,
renderID,
renderSentenceState,
renderStatementState,
renderTag,
Expand Down Expand Up @@ -41,7 +41,7 @@ interface DataGridProps {
}

type criteria =
| ("pmid" | "-pmid" | "last_edited" | "-last_edited")[]
| ("id" | "-id" | "last_edited" | "-last_edited")[]
| undefined;

const EntityDataGrid = (props: DataGridProps) => {
Expand All @@ -64,12 +64,12 @@ const EntityDataGrid = (props: DataGridProps) => {
notes: has_notes,
};
if (entityType === "sentence") {
const { pmid, text } = item;
return { ...commonRowProps, pmid, text };
const { id, text } = item;
return { ...commonRowProps, id, text };
}
if (entityType === "statement") {
const { sentence, knowledge_statement } = item;
return { ...commonRowProps, pmid: sentence.pmid, knowledge_statement };
const { id, knowledge_statement } = item;
return { ...commonRowProps, id: id, knowledge_statement };
}
return {};
};
Expand All @@ -78,7 +78,7 @@ const EntityDataGrid = (props: DataGridProps) => {
entityList?.map((item) => generateRowProps(item)) || [];

const columns: GridColDef[] = [
{ field: "pmid", headerName: "PMID", renderCell: renderPMID },
{ field: "id", headerName: "ID", renderCell: renderID },
{
field: entityType === "sentence" ? "text" : "knowledge_statement",
headerName:
Expand Down Expand Up @@ -145,10 +145,10 @@ const EntityDataGrid = (props: DataGridProps) => {
} else {
const { field, sort } = model[0];
const sortingCriteria = `${field} ${sort}`;
if (sortingCriteria === "pmid asc") {
ordering = ["pmid"];
} else if (sortingCriteria === "pmid desc") {
ordering = ["-pmid"];
if (sortingCriteria === "id asc") {
ordering = ["id"];
} else if (sortingCriteria === "id desc") {
ordering = ["-id"];
} else if (sortingCriteria === "last_edited asc") {
ordering = ["last_edited"];
} else if (sortingCriteria === "last_edited desc") {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/redux/sentenceSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface QueryParams {
limit: number,
notes: boolean | undefined,
index: number | undefined,
ordering: Array<'-last_edited' | '-pmid' | 'last_edited' | 'pmid'> | undefined,
ordering: Array<'-last_edited' | '-id' | 'last_edited' | 'id'> | undefined,
stateFilter: StateFilter | undefined,
tagFilter: number[] | undefined,
title: string | undefined
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/redux/statementSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface QueryParams {
notes: boolean | undefined;
index: number | undefined;
ordering:
| Array<"-last_edited" | "-pmid" | "last_edited" | "pmid">
| Array<"-last_edited" | "-id" | "last_edited" | "id">
| undefined;
stateFilter: StateFilter | undefined;
tagFilter: number[] | undefined;
Expand Down
8 changes: 4 additions & 4 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ paths:
items:
type: string
enum:
- -id
- -last_edited
- -pmid
- id
- last_edited
- pmid
description: Ordering
explode: false
style: form
Expand Down Expand Up @@ -893,10 +893,10 @@ paths:
items:
type: string
enum:
- -id
- -last_edited
- -pmid
- id
- last_edited
- pmid
description: Ordering
explode: false
style: form
Expand Down