Skip to content

Commit

Permalink
add admin view of new tables (#3265)(minor)
Browse files Browse the repository at this point in the history
## Description

Closes Clinical-Genomics/add-new-tech#22

Add table **Illumina Flow Cell** to StatusDB with the same columns as the **Flowcell** table and the same operations (search and sort).
  • Loading branch information
diitaz93 authored May 30, 2024
1 parent a8dec6c commit 6718b91
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
52 changes: 52 additions & 0 deletions cg/server/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def view_priority(unused1, unused2, model, unused3):
return Markup("%s" % model.priority.name) if model else ""


def view_flow_cell_internal_id(unused1, unused2, model, unused3):
"""column formatter for priority"""
del unused1, unused2, unused3
return Markup("%s" % model.device.internal_id)


def view_case_sample_link(unused1, unused2, model, unused3):
"""column formatter to open the case-sample view"""

Expand Down Expand Up @@ -441,6 +447,52 @@ class AnalysisView(BaseView):
form_extra_fields = {"workflow": SelectEnumField(enum_class=Workflow)}


class IlluminaFlowCellView(BaseView):
"""Admin view for Model.IlluminaSequencingRun"""

column_list = (
"internal_id",
"sequencer_type",
"sequencer_name",
"data_availability",
"has_backup",
"total_reads",
"total_undetermined_reads",
"percent_undetermined_reads",
"percent_q30",
"mean_quality_score",
"total_yield",
"yield_q30",
"cycles",
"demultiplexing_software",
"demultiplexing_software_version",
"sequencing_started_at",
"sequencing_completed_at",
"demultiplexing_started_at",
"demultiplexing_completed_at",
"archived_at",
)
column_formatters = {
"internal_id": view_flow_cell_internal_id,
}

column_default_sort = ("sequencing_completed_at", True)
column_filters = ["sequencer_type", "sequencer_name", "data_availability"]
column_editable_list = ["data_availability"]
column_searchable_list = ["sequencer_type", "sequencer_name", "device.internal_id"]
column_sortable_list = [
"sequencer_type",
"sequencer_name",
"data_availability",
"has_backup",
"sequencing_started_at",
"sequencing_completed_at",
"demultiplexing_started_at",
"demultiplexing_completed_at",
"archived_at",
]


class OrganismView(BaseView):
"""Admin view for Model.Organism"""

Expand Down
7 changes: 5 additions & 2 deletions cg/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from flask_dance.contrib.google import google, make_google_blueprint
from sqlalchemy.orm import scoped_session

from cg.server import admin, api, ext, invoices
from cg.store.database import get_scoped_session_registry
from cg.store.models import (
Analysis,
Expand All @@ -19,6 +20,7 @@
Collaboration,
Customer,
Flowcell,
IlluminaSequencingRun,
Invoice,
Order,
Organism,
Expand All @@ -29,8 +31,6 @@
User,
)

from . import admin, api, ext, invoices


def create_app():
"""Generate a flask application."""
Expand Down Expand Up @@ -128,6 +128,9 @@ def _register_admin_views():
ext.admin.add_view(admin.FlowcellView(Flowcell, ext.db.session))
ext.admin.add_view(admin.AnalysisView(Analysis, ext.db.session))
ext.admin.add_view(admin.InvoiceView(Invoice, ext.db.session))
ext.admin.add_view(
admin.IlluminaFlowCellView(IlluminaSequencingRun, ext.db.session, name="Illumina Flow Cell")
)


def _register_teardowns(app: Flask):
Expand Down
4 changes: 1 addition & 3 deletions cg/store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,7 @@ def to_dict(self):
class Collaboration(Base):
__tablename__ = "collaboration"
id: Mapped[PrimaryKeyInt]
internal_id: Mapped[Str32] = mapped_column(
unique=True,
)
internal_id: Mapped[Str32] = mapped_column(unique=True)
name: Mapped[Str128]
customers: Mapped[list[Customer]] = orm.relationship(
secondary="customer_collaboration", back_populates="collaborations"
Expand Down

0 comments on commit 6718b91

Please sign in to comment.