mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 01:42:30 -05:00
[V3 Setup] Overhaul backend conversion process through setup scripts (#2579)
* swap to click for setup * Initial changes * expose some stuff to allow for per-driver optimizations * overwrite base config * add red log * add one print juuuust in case * fix this * thanks kowlin * damn * oops * fix thing * partial commit * Working mongo -> json conversion, it sucks tho * remove unused line * Wrote initial optimized json importer * optimized json importer * remove useless line * update mongo to json converter * lets try writing the correct entry * oops * style fix * add some garbage data filters going from old mongo to json * ignore garbage data in mongov2 conversions * simplify code a bit and add a completion message * missed one * Update pipfile lock * Lock click version
This commit is contained in:
@@ -69,6 +69,9 @@ class JSON(BaseDriver):
|
||||
|
||||
self._load_data()
|
||||
|
||||
async def has_valid_connection(self) -> bool:
|
||||
return True
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return _shared_datastore.get(self.cog_name)
|
||||
@@ -123,5 +126,29 @@ class JSON(BaseDriver):
|
||||
else:
|
||||
await self.jsonIO._threadsafe_save_json(self.data)
|
||||
|
||||
async def import_data(self, cog_data, custom_group_data):
|
||||
def update_write_data(identifier_data: IdentifierData, data):
|
||||
partial = self.data
|
||||
idents = identifier_data.to_tuple()
|
||||
for ident in idents[:-1]:
|
||||
if ident not in partial:
|
||||
partial[ident] = {}
|
||||
partial = partial[ident]
|
||||
partial[idents[-1]] = data
|
||||
|
||||
for category, all_data in cog_data:
|
||||
splitted_pkey = self._split_primary_key(category, custom_group_data, all_data)
|
||||
for pkey, data in splitted_pkey:
|
||||
ident_data = IdentifierData(
|
||||
self.unique_cog_identifier,
|
||||
category,
|
||||
pkey,
|
||||
(),
|
||||
custom_group_data.get(category, {}),
|
||||
is_custom=category in custom_group_data,
|
||||
)
|
||||
update_write_data(ident_data, data)
|
||||
await self.jsonIO._threadsafe_save_json(self.data)
|
||||
|
||||
def get_config_details(self):
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user