mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-02-01 15:20:49 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29a64511b8 | ||
|
|
6bb045d761 |
@@ -158,6 +158,16 @@ def compare_yaml(old_data: Any,
|
|||||||
return changes
|
return changes
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_yaml_keys(data):
|
||||||
|
"""Convert boolean keys to strings in YAML data to avoid JSON serialization issues"""
|
||||||
|
if isinstance(data, dict):
|
||||||
|
return {str(k): normalize_yaml_keys(v) for k, v in data.items()}
|
||||||
|
elif isinstance(data, list):
|
||||||
|
return [normalize_yaml_keys(item) for item in data]
|
||||||
|
else:
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
def create_change_summary(old_data: Optional[Dict], new_data: Optional[Dict],
|
def create_change_summary(old_data: Optional[Dict], new_data: Optional[Dict],
|
||||||
file_path: str) -> Dict[str, Any]:
|
file_path: str) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
@@ -180,6 +190,9 @@ def create_change_summary(old_data: Optional[Dict], new_data: Optional[Dict],
|
|||||||
- changes: Detailed changes from compare_yaml
|
- changes: Detailed changes from compare_yaml
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
# Normalize keys to avoid JSON serialization issues with boolean keys
|
||||||
|
old_data = normalize_yaml_keys(old_data) if old_data else None
|
||||||
|
new_data = normalize_yaml_keys(new_data) if new_data else None
|
||||||
filename = os.path.basename(file_path)
|
filename = os.path.basename(file_path)
|
||||||
new_name = new_data.get("name") if new_data else None
|
new_name = new_data.get("name") if new_data else None
|
||||||
old_name = old_data.get("name") if old_data else None
|
old_name = old_data.get("name") if old_data else None
|
||||||
|
|||||||
@@ -153,6 +153,30 @@ def compare_primitive_arrays(ours_data: List, theirs_data: List,
|
|||||||
return conflicts
|
return conflicts
|
||||||
|
|
||||||
|
|
||||||
|
def format_array_for_display(data):
|
||||||
|
"""Format array data for display in conflict resolution"""
|
||||||
|
if isinstance(data, list):
|
||||||
|
if not data:
|
||||||
|
return "[] (empty array)"
|
||||||
|
elif all(isinstance(x, dict) and 'name' in x for x in data):
|
||||||
|
# Array of objects with names - show the names
|
||||||
|
names = [x['name'] for x in data]
|
||||||
|
if len(names) <= 5:
|
||||||
|
return f"[{', '.join(names)}]"
|
||||||
|
else:
|
||||||
|
return f"[{', '.join(names[:5])}, ... and {len(names) - 5} more]"
|
||||||
|
elif all(not isinstance(x, (dict, list)) for x in data):
|
||||||
|
# Array of primitives
|
||||||
|
if len(data) <= 5:
|
||||||
|
return f"[{', '.join(str(x) for x in data)}]"
|
||||||
|
else:
|
||||||
|
return f"[{', '.join(str(x) for x in data[:5])}, ... and {len(data) - 5} more]"
|
||||||
|
else:
|
||||||
|
# Mixed or complex array
|
||||||
|
return f"Array with {len(data)} items"
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
def compare_dicts(ours_data: Dict, theirs_data: Dict, path: str) -> List[Dict]:
|
def compare_dicts(ours_data: Dict, theirs_data: Dict, path: str) -> List[Dict]:
|
||||||
"""Compare dictionaries recursively"""
|
"""Compare dictionaries recursively"""
|
||||||
conflicts = []
|
conflicts = []
|
||||||
@@ -164,15 +188,23 @@ def compare_dicts(ours_data: Dict, theirs_data: Dict, path: str) -> List[Dict]:
|
|||||||
new_path = f"{path}.{key}" if path else key
|
new_path = f"{path}.{key}" if path else key
|
||||||
|
|
||||||
if key not in ours_data:
|
if key not in ours_data:
|
||||||
|
# Format arrays for better display when field is missing locally
|
||||||
|
incoming_val = theirs_data[key]
|
||||||
|
if isinstance(incoming_val, list):
|
||||||
|
incoming_val = format_array_for_display(incoming_val)
|
||||||
conflicts.append({
|
conflicts.append({
|
||||||
'parameter': new_path,
|
'parameter': new_path,
|
||||||
'local_value': None,
|
'local_value': None,
|
||||||
'incoming_value': theirs_data[key]
|
'incoming_value': incoming_val
|
||||||
})
|
})
|
||||||
elif key not in theirs_data:
|
elif key not in theirs_data:
|
||||||
|
# Format arrays for better display when field is missing remotely
|
||||||
|
local_val = ours_data[key]
|
||||||
|
if isinstance(local_val, list):
|
||||||
|
local_val = format_array_for_display(local_val)
|
||||||
conflicts.append({
|
conflicts.append({
|
||||||
'parameter': new_path,
|
'parameter': new_path,
|
||||||
'local_value': ours_data[key],
|
'local_value': local_val,
|
||||||
'incoming_value': None
|
'incoming_value': None
|
||||||
})
|
})
|
||||||
elif ours_data[key] != theirs_data[key]:
|
elif ours_data[key] != theirs_data[key]:
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
services:
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
build: ./frontend
|
build: ./frontend
|
||||||
@@ -19,6 +18,4 @@ services:
|
|||||||
- ./config:/config
|
- ./config:/config
|
||||||
environment:
|
environment:
|
||||||
- TZ=Australia/Adelaide
|
- TZ=Australia/Adelaide
|
||||||
env_file:
|
restart: always
|
||||||
- .env
|
|
||||||
restart: always
|
|
||||||
|
|||||||
Reference in New Issue
Block a user