Skip to content

Commit

Permalink
refactor plugin setting lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
7dJx1qP committed Feb 13, 2024
1 parent 081abb9 commit 67db740
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
log.LogDebug(f"databasePath: {database_path}")

def get_fields():
settings = client.callGraphQL("""query Configuration { configuration { plugins } }""")['configuration']['plugins']
if settings and 'stashPerformerCustomFields' in settings and 'fields' in settings['stashPerformerCustomFields']:
fields = settings['stashPerformerCustomFields']['fields']
fields = (fields or 'notes,paths,urls').split(',')
plugin_settings = client.callGraphQL("""query Configuration { configuration { plugins } }""")['configuration']['plugins'].get('stashPerformerCustomFields', {})
fields = plugin_settings.get('fields', 'notes,paths,urls').replace(' ', '').split(',')
log.LogDebug(f'fields: {json.dumps(fields)}')
return fields

Expand Down
22 changes: 2 additions & 20 deletions plugins/stashStashboxSceneCount/stashStashboxSceneCount.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ def get_database_config():
log.debug(f"databasePath: {database_path}")
return database_path, blobs_path, blobs_storage

settings = client.callGraphQL("""query Configuration { configuration { plugins } }""")['configuration']['plugins']
if settings and 'stashStashboxSceneCount' in settings:
pluginSettings = settings['stashStashboxSceneCount']
else:
pluginSettings = {}
plugin_settings = client.callGraphQL("""query Configuration { configuration { plugins } }""")['configuration']['plugins'].get('stashStashboxSceneCount', {})
include_subsidiary_studios = plugin_settings.get('includeSubsidiaryStudios', False)

try:
db = StashDatabase(*get_database_config())
Expand All @@ -41,13 +38,6 @@ def get_database_config():
if name == 'stashbox_performer_scene_count':
log.debug(f"stashbox_performer_scene_count: endpoint={endpoint}, stash_id={stash_id}")
scene_count = stashbox_performer_scene_count(endpoint, api_key, stash_id)
# pluginSettings['performerCount'] = scene_count
# variables = {
# "plugin_id": "stashStashboxSceneCount",
# "input": pluginSettings
# }
# # log.debug(f"{stash_id}: {scene_count}")
# client.callGraphQL("""mutation ConfigurePlugin($plugin_id: ID!, $input: Map!) { configurePlugin(plugin_id: $plugin_id, input: $input) }""", variables)
database_scene_count = db.fetchone("""SELECT COUNT(DISTINCT b.stash_id)
FROM scenes a
JOIN scene_stash_ids b ON a.id = b.scene_id
Expand All @@ -57,16 +47,8 @@ def get_database_config():
log.debug(f"{stash_id}: {database_scene_count}/{scene_count}")
elif name == 'stashbox_studio_scene_count':
log.debug(f"stashbox_studio_scene_count: endpoint={endpoint}, stash_id={stash_id}")
include_subsidiary_studios = 'includeSubsidiaryStudios' in pluginSettings and pluginSettings['includeSubsidiaryStudios']
log.debug(f"include_subsidiary_studios: {include_subsidiary_studios}")
scene_count = stashbox_studio_scene_count(endpoint, api_key, stash_id, include_subsidiary_studios)
# pluginSettings['studioCount'] = scene_count
# variables = {
# "plugin_id": "stashStashboxSceneCount",
# "input": pluginSettings
# }
# # log.debug(f"{stash_id}: {scene_count}")
# client.callGraphQL("""mutation ConfigurePlugin($plugin_id: ID!, $input: Map!) { configurePlugin(plugin_id: $plugin_id, input: $input) }""", variables)
if not include_subsidiary_studios:
database_scene_count = db.fetchone("""SELECT COUNT(DISTINCT b.stash_id)
FROM scenes a
Expand Down

0 comments on commit 67db740

Please sign in to comment.