Skip to content

Commit

Permalink
refactor(crud and models) (#99) (patch)
Browse files Browse the repository at this point in the history
# Description

Refactor crud models
  • Loading branch information
ChrOertlin authored Mar 12, 2024
1 parent 38b2d65 commit c7bcaf1
Show file tree
Hide file tree
Showing 24 changed files with 590 additions and 575 deletions.
Binary file added database.db
Binary file not shown.
2 changes: 1 addition & 1 deletion genotype_api/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from fastapi.middleware.cors import CORSMiddleware

from genotype_api.config import security_settings
from genotype_api.database import create_db_and_tables
from genotype_api.database.session_handler import create_db_and_tables
from genotype_api.api.endpoints import samples, snps, users, plates, analyses
from sqlalchemy.exc import NoResultFound

Expand Down
21 changes: 10 additions & 11 deletions genotype_api/api/endpoints/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
from fastapi import APIRouter, Depends, status, Query, UploadFile, File
from fastapi.responses import JSONResponse

from genotype_api.crud.analyses import (
get_analysis,
check_analyses_objects,
create_analysis,
)
from genotype_api.crud.samples import (
create_analyses_sample_objects,
refresh_sample_status,
)
from genotype_api.database import get_session
from genotype_api.database.crud.read import get_analysis, check_analyses_objects
from genotype_api.database.crud.create import create_analysis, create_analyses_sample_objects
from genotype_api.database.crud.update import refresh_sample_status
from genotype_api.database.session_handler import get_session
from genotype_api.file_parsing.files import check_file
from genotype_api.models import Analysis, AnalysisRead, AnalysisReadWithGenotype, User
from genotype_api.database.models import (
Analysis,
AnalysisRead,
User,
AnalysisReadWithGenotype,
)
from sqlmodel import Session, select

from genotype_api.security import get_active_user
Expand Down
23 changes: 10 additions & 13 deletions genotype_api/api/endpoints/plates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,23 @@
from sqlalchemy import desc, asc
from sqlmodel import Session, select

from genotype_api.crud.analyses import (
from genotype_api.database.crud.read import (
get_analyses_from_plate,
get_plate,
get_user_by_email,
check_analyses_objects,
)
from genotype_api.crud.samples import (
create_analyses_sample_objects,
refresh_sample_status,
)
from genotype_api.crud.plates import create_plate, get_plate
from genotype_api.crud.users import get_user_by_email
from genotype_api.database import get_session
from genotype_api.database.crud.update import refresh_sample_status
from genotype_api.database.crud.create import create_plate, create_analyses_sample_objects
from genotype_api.database.session_handler import get_session
from genotype_api.file_parsing.excel import GenotypeAnalysis
from genotype_api.file_parsing.files import check_file
from genotype_api.models import (
Plate,
PlateReadWithAnalyses,
from genotype_api.database.models import (
Analysis,
PlateCreate,
User,
PlateRead,
Plate,
PlateCreate,
PlateReadWithAnalyses,
PlateReadWithAnalysisDetail,
PlateReadWithAnalysisDetailSingle,
)
Expand Down
25 changes: 13 additions & 12 deletions genotype_api/api/endpoints/samples.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
from typing import List, Optional, Literal
from fastapi import APIRouter, Depends, Query
from fastapi.responses import JSONResponse
from datetime import datetime, timedelta, date
from datetime import timedelta, date
from starlette import status

import genotype_api.database.crud.create
from genotype_api.constants import SEXES
from genotype_api.database import get_session
from genotype_api.database.session_handler import get_session
from genotype_api.match import check_sample
from genotype_api.models import (
Sample,
SampleReadWithAnalysis,
SampleRead,
User,
SampleDetail,
Analysis,
MatchResult,
MatchCounts,
)
from genotype_api.database.models import (
Analysis,
Sample,
SampleRead,
User,
SampleReadWithAnalysisDeep,
compare_genotypes,
)
from collections import Counter
from genotype_api import crud
from genotype_api.crud.samples import (
from genotype_api.database.crud.update import refresh_sample_status
from genotype_api.database.crud.read import (
get_incomplete_samples,
get_plate_samples,
get_commented_samples,
get_sample,
get_status_missing_samples,
refresh_sample_status,
get_sample,
get_samples,
)
from sqlmodel import Session, select
Expand Down Expand Up @@ -118,7 +119,7 @@ def create_sample(
session: Session = Depends(get_session),
current_user: User = Depends(get_active_user),
):
return crud.samples.create_sample(session=session, sample=sample)
return genotype_api.database.database.crud.create.create_sample(session=session, sample=sample)


@router.put("/{sample_id}/sex", response_model=SampleRead)
Expand Down
6 changes: 3 additions & 3 deletions genotype_api/api/endpoints/snps.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Routes for the snps"""

from genotype_api.models import SNP, User
from genotype_api.database.models import SNP, User
from typing import List

from fastapi import APIRouter, Depends, HTTPException, Query, File, UploadFile
from genotype_api.database import get_session
from fastapi import APIRouter, Depends, HTTPException, Query, UploadFile
from genotype_api.database.session_handler import get_session
from sqlmodel import Session, delete, select

from genotype_api.security import get_active_user
Expand Down
8 changes: 4 additions & 4 deletions genotype_api/api/endpoints/users.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""Routes for users"""

from typing import List, Optional
from typing import List

from fastapi import APIRouter, Depends, HTTPException, Query
from pydantic import EmailStr
from starlette import status
from starlette.responses import JSONResponse

from genotype_api.crud.users import get_user
from genotype_api.database import get_session
from genotype_api.models import User, UserRead, UserCreate, UserReadWithPlates
from genotype_api.database.crud.read import get_user
from genotype_api.database.session_handler import get_session
from genotype_api.database.models import User, UserRead, UserCreate, UserReadWithPlates
from sqlmodel import Session, select

from genotype_api.security import get_active_user
Expand Down
60 changes: 0 additions & 60 deletions genotype_api/crud/analyses.py

This file was deleted.

38 changes: 0 additions & 38 deletions genotype_api/crud/plates.py

This file was deleted.

83 changes: 0 additions & 83 deletions genotype_api/crud/samples.py

This file was deleted.

32 changes: 0 additions & 32 deletions genotype_api/crud/users.py

This file was deleted.

File renamed without changes.
Empty file.
Loading

0 comments on commit c7bcaf1

Please sign in to comment.