mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-22 10:51:02 +01:00
feat: add function to retrieve unique import settings for multiple arr IDs
This commit is contained in:
@@ -156,3 +156,34 @@ def save_settings(settings_dict):
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
''', (key, value))
|
||||
conn.commit()
|
||||
|
||||
|
||||
def get_unique_arrs(arr_ids):
|
||||
"""
|
||||
Get import_as_unique settings for a list of arr IDs.
|
||||
|
||||
Args:
|
||||
arr_ids (list): List of arr configuration IDs
|
||||
|
||||
Returns:
|
||||
dict: Dictionary mapping arr IDs to their import_as_unique settings and names
|
||||
"""
|
||||
if not arr_ids:
|
||||
return {}
|
||||
|
||||
with get_db() as conn:
|
||||
placeholders = ','.join('?' * len(arr_ids))
|
||||
query = f'''
|
||||
SELECT id, name, import_as_unique
|
||||
FROM arr_config
|
||||
WHERE id IN ({placeholders})
|
||||
'''
|
||||
|
||||
results = conn.execute(query, arr_ids).fetchall()
|
||||
return {
|
||||
row['id']: {
|
||||
'import_as_unique': bool(row['import_as_unique']),
|
||||
'name': row['name']
|
||||
}
|
||||
for row in results
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user