diff --git a/backend/app/routers/sample.py b/backend/app/routers/sample.py index bb4b695..248bba7 100644 --- a/backend/app/routers/sample.py +++ b/backend/app/routers/sample.py @@ -22,7 +22,7 @@ router = APIRouter() @router.get("/{puck_id}/samples", response_model=List[SampleSchema]) -async def get_samples_with_events(puck_id: str, db: Session = Depends(get_db)): +async def get_samples_with_events(puck_id: int, db: Session = Depends(get_db)): puck = db.query(PuckModel).filter(PuckModel.id == puck_id).first() if not puck: raise HTTPException(status_code=404, detail="Puck not found") @@ -46,6 +46,8 @@ async def get_all_pucks_with_samples_and_events(db: Session = Depends(get_db)): pucks = db.query(PuckModel).all() logging.info(f"Found {len(pucks)} pucks in the database") for puck in pucks: + if puck.dewar_id is None: + puck.dewar_id = -1 logging.info(f"Puck ID: {puck.id}, Name: {puck.puck_name}") if not pucks: diff --git a/frontend/src/components/SampleTracker.tsx b/frontend/src/components/SampleTracker.tsx index 5f8c5f4..425b1ed 100644 --- a/frontend/src/components/SampleTracker.tsx +++ b/frontend/src/components/SampleTracker.tsx @@ -32,7 +32,7 @@ const SampleTracker: React.FC = () => { const fetchPucks = async () => { try { const data: Puck[] = await SamplesService.getAllPucksWithSamplesAndEventsSamplesPucksSamplesGet(); - console.log(data); // Log the data to inspect it + console.log(data); setPucks(data); } catch (error) { console.error("Error fetching pucks", error); diff --git a/testfunctions.ipynb b/testfunctions.ipynb index ba193c5..ae6efd0 100644 --- a/testfunctions.ipynb +++ b/testfunctions.ipynb @@ -6,8 +6,8 @@ "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2025-01-10T10:16:49.228369Z", - "start_time": "2025-01-10T10:16:49.224212Z" + "end_time": "2025-01-10T11:42:48.076458Z", + "start_time": "2025-01-10T11:42:48.071372Z" } }, "source": [ @@ -21,8 +21,8 @@ "print(aareDBclient.__version__)\n", "\n", "configuration = aareDBclient.Configuration(\n", - " #host = \"https://mx-aare-test.psi.ch:1492\"\n", - " host = \"https://127.0.0.1:8000\"\n", + " host = \"https://mx-aare-test.psi.ch:1492\"\n", + " #host = \"https://127.0.0.1:8000\"\n", ")\n", "\n", "configuration.verify_ssl = False # Disable SSL verification\n", @@ -38,13 +38,13 @@ ] } ], - "execution_count": 3 + "execution_count": 8 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-01-10T10:16:52.480280Z", - "start_time": "2025-01-10T10:16:52.454958Z" + "end_time": "2025-01-10T11:42:50.424118Z", + "start_time": "2025-01-10T11:42:50.385515Z" } }, "cell_type": "code", @@ -71,25 +71,32 @@ "text": [ "The response of PucksApi->get_pucks_by_slot_pucks_slot_slot_identifier_get:\n", "\n", - "[PuckWithTellPosition(id=31, puck_name='CPS-4093', puck_type='unipuck', puck_location_in_dewar=1, dewar_id=6, dewar_name='Dewar_test', user='e16371', samples=None, tell_position='C2'),\n", - " PuckWithTellPosition(id=32, puck_name='CPS-4178', puck_type='unipuck', puck_location_in_dewar=2, dewar_id=6, dewar_name='Dewar_test', user='e16371', samples=None, tell_position='C3'),\n", - " PuckWithTellPosition(id=33, puck_name='PSIMX-122', puck_type='unipuck', puck_location_in_dewar=3, dewar_id=6, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None),\n", - " PuckWithTellPosition(id=34, puck_name='E-07', puck_type='unipuck', puck_location_in_dewar=4, dewar_id=6, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None),\n", - " PuckWithTellPosition(id=35, puck_name='CPS-6597', puck_type='unipuck', puck_location_in_dewar=5, dewar_id=6, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None),\n", - " PuckWithTellPosition(id=36, puck_name='PSIMX-078', puck_type='unipuck', puck_location_in_dewar=6, dewar_id=6, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None),\n", - " PuckWithTellPosition(id=37, puck_name='1002', puck_type='unipuck', puck_location_in_dewar=7, dewar_id=6, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None)]\n" + "[PuckWithTellPosition(id=1, puck_name='CPS-4093', puck_type='unipuck', puck_location_in_dewar=1, dewar_id=1, dewar_name='Dewar_test', user='e16371', samples=None, tell_position='D1'),\n", + " PuckWithTellPosition(id=2, puck_name='CPS-4178', puck_type='unipuck', puck_location_in_dewar=2, dewar_id=1, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=3, puck_name='PSIMX-122', puck_type='unipuck', puck_location_in_dewar=3, dewar_id=1, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=4, puck_name='E-07', puck_type='unipuck', puck_location_in_dewar=4, dewar_id=1, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=5, puck_name='CPS-6597', puck_type='unipuck', puck_location_in_dewar=5, dewar_id=1, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=6, puck_name='PSIMX-078', puck_type='unipuck', puck_location_in_dewar=6, dewar_id=1, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=7, puck_name='1002', puck_type='unipuck', puck_location_in_dewar=7, dewar_id=1, dewar_name='Dewar_test', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=15, puck_name='PSIMX123', puck_type='unipuck', puck_location_in_dewar=1, dewar_id=4, dewar_name='Huang', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=16, puck_name='PSIMX125', puck_type='unipuck', puck_location_in_dewar=2, dewar_id=4, dewar_name='Huang', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=17, puck_name='PSIMX127', puck_type='unipuck', puck_location_in_dewar=3, dewar_id=4, dewar_name='Huang', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=18, puck_name='PSIMX128', puck_type='unipuck', puck_location_in_dewar=4, dewar_id=4, dewar_name='Huang', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=19, puck_name='PSIMX130', puck_type='unipuck', puck_location_in_dewar=5, dewar_id=4, dewar_name='Huang', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=20, puck_name='PSIMX131', puck_type='unipuck', puck_location_in_dewar=6, dewar_id=4, dewar_name='Huang', user='e16371', samples=None, tell_position=None),\n", + " PuckWithTellPosition(id=21, puck_name='PSIMX132', puck_type='unipuck', puck_location_in_dewar=7, dewar_id=4, dewar_name='Huang', user='e16371', samples=None, tell_position=None)]\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", + "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'mx-aare-test.psi.ch'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] } ], - "execution_count": 4 + "execution_count": 9 }, { "metadata": { @@ -271,8 +278,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-09T19:41:23.052434Z", - "start_time": "2025-01-09T19:41:23.036108Z" + "end_time": "2025-01-10T11:43:57.303671Z", + "start_time": "2025-01-10T11:43:57.285551Z" } }, "cell_type": "code", @@ -284,7 +291,7 @@ "\n", " try:\n", " # Get the last sample event\n", - " last_event_response = api_instance.get_last_sample_event_samples_samples_sample_id_events_last_get(261)\n", + " last_event_response = api_instance.get_last_sample_event_samples_samples_sample_id_events_last_get(14)\n", " print(\"The response of get_last_sample_event:\\n\")\n", " pprint(last_event_response)\n", "\n", @@ -299,19 +306,19 @@ "text": [ "The response of get_last_sample_event:\n", "\n", - "SampleEventResponse(id=418, sample_id=261, event_type='Failed', timestamp=datetime.datetime(2025, 1, 9, 20, 41, 14))\n" + "SampleEventResponse(id=3, sample_id=14, event_type='Unmounted', timestamp=datetime.datetime(2025, 1, 10, 5, 53, 38))\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", + "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'mx-aare-test.psi.ch'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] } ], - "execution_count": 71 + "execution_count": 11 } ], "metadata": {