api function to remove oboslete settings parameters

This commit is contained in:
avollkopf 2023-04-08 14:15:08 +02:00
parent efc3e3737c
commit 668705e1e0
3 changed files with 27 additions and 2 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.1.8.a9" __version__ = "4.1.8.a10"
__codename__ = "Groundhog Day" __codename__ = "Groundhog Day"

View file

@ -78,3 +78,15 @@ class ConfigController:
json.dump(data, file, indent=4, sort_keys=True) json.dump(data, file, indent=4, sort_keys=True)
self.cache=self.testcache self.cache=self.testcache
async def remove_obsolete(self):
result = {}
for key, value in self.cache.items():
if (value.source not in ('craftbeerpi','steps','hidden')):
test = await self.cbpi.plugin.load_plugin_list(value.source)
if test == []:
update=self.get(str(value.source)+'_update')
if update:
await self.remove(str(value.source)+'_update')
await self.remove(key)
result[key] = value.to_dict()
return result

View file

@ -103,3 +103,16 @@ class ConfigHttpEndpoints:
name = request.match_info['name'] name = request.match_info['name']
await self.controller.remove(name=name) await self.controller.remove(name=name)
return web.Response(status=200) return web.Response(status=200)
@request_mapping(path="/obsolete", auth_required=False)
async def http_remove_obsolete(self, request) -> web.Response:
"""
---
description: Get all config parameters
tags:
- Config
responses:
"200":
description: successful operation
"""
return web.json_response(await self.controller.remove_obsolete(), dumps=json_dumps)