Skip to content

Commit

Permalink
CELE-18 Fix issue with nullable primary key (trick at the moment)
Browse files Browse the repository at this point in the history
  • Loading branch information
aranega committed Apr 25, 2024
1 parent d817833 commit e58dc1d
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 75 deletions.
97 changes: 65 additions & 32 deletions applications/visualizer/api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,53 @@
]
}
},
"/api/datasets/{dataset}/neurons": {
"get": {
"operationId": "get_dataset_neurons",
"summary": "Get Dataset Neurons",
"parameters": [
{
"in": "path",
"name": "dataset",
"schema": {
"title": "Dataset",
"type": "string"
},
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/Neuron"
},
"title": "Response",
"type": "array"
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorMessage"
}
}
}
}
},
"description": "Returns all the neurons of a dedicated dataset",
"tags": [
"datasets"
]
}
},
"/api/cells": {
"get": {
"operationId": "get_all_cells",
Expand Down Expand Up @@ -165,16 +212,8 @@
"Dataset": {
"properties": {
"id": {
"anyOf": [
{
"maxLength": 20,
"type": "string"
},
{
"type": "null"
}
],
"title": "Id"
"title": "Id",
"type": "string"
},
"collection": {
"maxLength": 20,
Expand Down Expand Up @@ -216,6 +255,7 @@
}
},
"required": [
"id",
"collection",
"name",
"description",
Expand All @@ -239,31 +279,11 @@
"title": "ErrorMessage",
"type": "object"
},
"Input": {
"properties": {
"page": {
"default": 1,
"minimum": 1,
"title": "Page",
"type": "integer"
}
},
"title": "Input",
"type": "object"
},
"Neuron": {
"properties": {
"name": {
"anyOf": [
{
"maxLength": 30,
"type": "string"
},
{
"type": "null"
}
],
"title": "Name"
"title": "Name",
"type": "string"
},
"nclass": {
"maxLength": 30,
Expand Down Expand Up @@ -297,13 +317,26 @@
}
},
"required": [
"name",
"nclass",
"neurotransmitter",
"type"
],
"title": "Neuron",
"type": "object"
},
"Input": {
"properties": {
"page": {
"default": 1,
"minimum": 1,
"title": "Page",
"type": "integer"
}
},
"title": "Input",
"type": "object"
},
"PagedNeuron": {
"properties": {
"items": {
Expand Down
14 changes: 7 additions & 7 deletions applications/visualizer/backend/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ class Dataset(Model):
# CONSTRAINT pk_neurons PRIMARY KEY (name)
# );
class Neuron(Model):
name = CharField(max_length=30, primary_key=True, null=False)
nclass = CharField(max_length=30, null=False)
neurotransmitter = CharField(max_length=10, null=False)
type = CharField(max_length=10, null=False)
embryonic = BooleanField(null=False, default=False)
inhead = BooleanField(null=False, default=False)
intail = BooleanField(null=False, default=False)
name = CharField(max_length=30, primary_key=True)
nclass = CharField(max_length=30)
neurotransmitter = CharField(max_length=10)
type = CharField(max_length=10)
embryonic = BooleanField(default=False)
inhead = BooleanField(default=False)
intail = BooleanField(default=False)


# DROP TABLE IF EXISTS annotations;
Expand Down
6 changes: 4 additions & 2 deletions applications/visualizer/backend/api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ class Config(Schema.Config):


class Dataset(ModelSchema, BilingualSchema):
id: str

class Meta:
model = DatasetModel
fields = [
"id",
"collection",
"name",
"description",
Expand All @@ -35,10 +36,11 @@ class Meta:


class Neuron(ModelSchema, BilingualSchema):
name: str

class Meta:
model = NeuronModel
fields = [
"name",
"nclass",
"neurotransmitter",
"type",
Expand Down
97 changes: 65 additions & 32 deletions applications/visualizer/backend/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,53 @@
]
}
},
"/api/datasets/{dataset}/neurons": {
"get": {
"operationId": "get_dataset_neurons",
"summary": "Get Dataset Neurons",
"parameters": [
{
"in": "path",
"name": "dataset",
"schema": {
"title": "Dataset",
"type": "string"
},
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/Neuron"
},
"title": "Response",
"type": "array"
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorMessage"
}
}
}
}
},
"description": "Returns all the neurons of a dedicated dataset",
"tags": [
"datasets"
]
}
},
"/api/cells": {
"get": {
"operationId": "get_all_cells",
Expand Down Expand Up @@ -165,16 +212,8 @@
"Dataset": {
"properties": {
"id": {
"anyOf": [
{
"maxLength": 20,
"type": "string"
},
{
"type": "null"
}
],
"title": "Id"
"title": "Id",
"type": "string"
},
"collection": {
"maxLength": 20,
Expand Down Expand Up @@ -216,6 +255,7 @@
}
},
"required": [
"id",
"collection",
"name",
"description",
Expand All @@ -239,31 +279,11 @@
"title": "ErrorMessage",
"type": "object"
},
"Input": {
"properties": {
"page": {
"default": 1,
"minimum": 1,
"title": "Page",
"type": "integer"
}
},
"title": "Input",
"type": "object"
},
"Neuron": {
"properties": {
"name": {
"anyOf": [
{
"maxLength": 30,
"type": "string"
},
{
"type": "null"
}
],
"title": "Name"
"title": "Name",
"type": "string"
},
"nclass": {
"maxLength": 30,
Expand Down Expand Up @@ -297,13 +317,26 @@
}
},
"required": [
"name",
"nclass",
"neurotransmitter",
"type"
],
"title": "Neuron",
"type": "object"
},
"Input": {
"properties": {
"page": {
"default": 1,
"minimum": 1,
"title": "Page",
"type": "integer"
}
},
"title": "Input",
"type": "object"
},
"PagedNeuron": {
"properties": {
"items": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* tslint:disable */
/* eslint-disable */
export type Dataset = {
id?: (string | null);
id: string;
collection: string;
name: string;
description: string;
Expand Down
2 changes: 1 addition & 1 deletion applications/visualizer/frontend/src/rest/models/Neuron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* tslint:disable */
/* eslint-disable */
export type Neuron = {
name?: (string | null);
name: string;
nclass: string;
neurotransmitter: string;
type: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* tslint:disable */
/* eslint-disable */
import type { Dataset } from '../models/Dataset';
import type { Neuron } from '../models/Neuron';
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
Expand Down Expand Up @@ -41,4 +42,26 @@ export class DatasetsService {
},
});
}
/**
* Get Dataset Neurons
* Returns all the neurons of a dedicated dataset
* @returns Neuron OK
* @throws ApiError
*/
public static getDatasetNeurons({
dataset,
}: {
dataset: string,
}): CancelablePromise<Array<Neuron>> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/datasets/{dataset}/neurons',
path: {
'dataset': dataset,
},
errors: {
404: `Not Found`,
},
});
}
}

0 comments on commit e58dc1d

Please sign in to comment.