refactored frequency_khz to frequencies
This commit is contained in:
@@ -179,7 +179,7 @@ async def example_mongo_usage():
|
|||||||
channel_data = {
|
channel_data = {
|
||||||
"_id": "channel_3", # You can specify _id or let MongoDB generate one
|
"_id": "channel_3", # You can specify _id or let MongoDB generate one
|
||||||
"name": "Emergency Services",
|
"name": "Emergency Services",
|
||||||
"frequency_khz": 453000,
|
"frequencies": 453000,
|
||||||
"location": "Countywide",
|
"location": "Countywide",
|
||||||
"avail_on_nodes": ["client-xyz987"],
|
"avail_on_nodes": ["client-xyz987"],
|
||||||
"description": "Monitor for emergency broadcasts."
|
"description": "Monitor for emergency broadcasts."
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class System:
|
|||||||
_id: str,
|
_id: str,
|
||||||
_type: DemodTypes,
|
_type: DemodTypes,
|
||||||
name: str,
|
name: str,
|
||||||
frequency_khz: List[str],
|
frequencies: List[str],
|
||||||
location: str,
|
location: str,
|
||||||
avail_on_nodes: List[str],
|
avail_on_nodes: List[str],
|
||||||
description: Optional[str] = "",
|
description: Optional[str] = "",
|
||||||
@@ -109,7 +109,7 @@ class System:
|
|||||||
_id: A unique identifier for the entry (e.g., MongoDB ObjectId string).
|
_id: A unique identifier for the entry (e.g., MongoDB ObjectId string).
|
||||||
_type: The demodulation type (P25, NBFM, etc.).
|
_type: The demodulation type (P25, NBFM, etc.).
|
||||||
name: The name of the channel/system.
|
name: The name of the channel/system.
|
||||||
frequency_khz: The frequency in kilohertz.
|
frequencies: The frequency in kilohertz.
|
||||||
location: The geographical location or coverage area.
|
location: The geographical location or coverage area.
|
||||||
avail_on_nodes: A list of node identifiers where this is available.
|
avail_on_nodes: A list of node identifiers where this is available.
|
||||||
description: A brief description.
|
description: A brief description.
|
||||||
@@ -117,7 +117,7 @@ class System:
|
|||||||
self._id: str = str(_id)
|
self._id: str = str(_id)
|
||||||
self.type: DemodTypes = _type
|
self.type: DemodTypes = _type
|
||||||
self.name: str = name
|
self.name: str = name
|
||||||
self.frequency_khz: List[int] = frequency_khz
|
self.frequencies: List[int] = frequencies
|
||||||
self.location: str = location
|
self.location: str = location
|
||||||
self.avail_on_nodes: List[str] = avail_on_nodes
|
self.avail_on_nodes: List[str] = avail_on_nodes
|
||||||
self.description: str = description or ""
|
self.description: str = description or ""
|
||||||
@@ -130,7 +130,7 @@ class System:
|
|||||||
"""
|
"""
|
||||||
# Use self.type.value for string representation of the enum
|
# Use self.type.value for string representation of the enum
|
||||||
return (f"System(_id='{self._id}', type='{self.type.value}', name='{self.name}', "
|
return (f"System(_id='{self._id}', type='{self.type.value}', name='{self.name}', "
|
||||||
f"frequency_khz={self.frequency_khz}, location='{self.location}', "
|
f"frequencies={self.frequencies}, location='{self.location}', "
|
||||||
f"avail_on_nodes={self.avail_on_nodes}, description='{self.description}',"
|
f"avail_on_nodes={self.avail_on_nodes}, description='{self.description}',"
|
||||||
f" tags='{self.tags}', whitelist='{self.whitelist}')")
|
f" tags='{self.tags}', whitelist='{self.whitelist}')")
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ class System:
|
|||||||
"_id": self._id,
|
"_id": self._id,
|
||||||
"type": self.type.value, # Store the enum value (string)
|
"type": self.type.value, # Store the enum value (string)
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
"frequency_khz": self.frequency_khz,
|
"frequencies": self.frequencies,
|
||||||
"location": self.location,
|
"location": self.location,
|
||||||
"avail_on_nodes": self.avail_on_nodes,
|
"avail_on_nodes": self.avail_on_nodes,
|
||||||
"description": self.description,
|
"description": self.description,
|
||||||
@@ -171,7 +171,7 @@ class System:
|
|||||||
_id=data.get("_id"),
|
_id=data.get("_id"),
|
||||||
_type=system_type,
|
_type=system_type,
|
||||||
name=data.get("name", ""), # Provide default empty string if name is missing
|
name=data.get("name", ""), # Provide default empty string if name is missing
|
||||||
frequency_khz=data.get("frequency_khz", 0), # Provide default 0 if missing
|
frequencies=data.get("frequencies", 0), # Provide default 0 if missing
|
||||||
location=data.get("location", ""),
|
location=data.get("location", ""),
|
||||||
avail_on_nodes=data.get("avail_on_nodes", []), # Provide default empty list
|
avail_on_nodes=data.get("avail_on_nodes", []), # Provide default empty list
|
||||||
description=data.get("description", ""),
|
description=data.get("description", ""),
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ async def create_system_route():
|
|||||||
if name_search_result:
|
if name_search_result:
|
||||||
abort(409, f"System with name '{request_data['name']}' already exists")
|
abort(409, f"System with name '{request_data['name']}' already exists")
|
||||||
|
|
||||||
# Check if frequency_khz exists (optional, depending on requirements)
|
# Check if frequencies exists (optional, depending on requirements)
|
||||||
if 'frequency_khz' in request_data:
|
if 'frequencies' in request_data:
|
||||||
freq_search_result = await current_app.sys_db_h.find_system({"frequency_khz": request_data["frequency_khz"]})
|
freq_search_result = await current_app.sys_db_h.find_system({"frequencies": request_data["frequencies"]})
|
||||||
if freq_search_result:
|
if freq_search_result:
|
||||||
abort(409, f"System with frequency '{request_data['frequency_khz']}' already exists")
|
abort(409, f"System with frequency '{request_data['frequencies']}' already exists")
|
||||||
|
|
||||||
created_system = await current_app.sys_db_h.create_system(request_data)
|
created_system = await current_app.sys_db_h.create_system(request_data)
|
||||||
|
|
||||||
@@ -262,8 +262,8 @@ async def dismiss_client_from_system_route(system_id: str):
|
|||||||
async def search_systems_route():
|
async def search_systems_route():
|
||||||
"""
|
"""
|
||||||
API endpoint to search for systems based on query parameters.
|
API endpoint to search for systems based on query parameters.
|
||||||
Allows searching by 'name', 'frequency_khz', or any other field present in the System model.
|
Allows searching by 'name', 'frequencies', or any other field present in the System model.
|
||||||
Example: /systems/search?name=MySystem&frequency_khz=1000
|
Example: /systems/search?name=MySystem&frequencies=1000
|
||||||
"""
|
"""
|
||||||
print("\n--- Handling GET /systems/search ---")
|
print("\n--- Handling GET /systems/search ---")
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user