Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Cleanup / Unused Config Cleanup #92

Open
aa-matthias opened this issue Jun 30, 2022 · 0 comments
Open

Data Cleanup / Unused Config Cleanup #92

aa-matthias opened this issue Jun 30, 2022 · 0 comments

Comments

@aa-matthias
Copy link

aa-matthias commented Jun 30, 2022

Please describe the feature you would like to see implemented.

It would be great to have a Data Cleanup tab that is listing unused data making cleanup easier

  • Unused Rule Builder Rules
  • Unused Product Streams
    • Used at least in product_export, category, product_cross_selling, rule_condition and cms_slot_translation (slot = product-slider)

Otherwise Cleaning Up is dangerous currently - deleting a Product Stream is possible even if the Stream is assigned to a product_export / rule_condition

For Rules situation is improving in the backend with a "assignments" tab within the rule edit view but filtering for unused rules is also not possible.

Next to the listed Entities there should be an action to either edit or delete the entity.

What's making it a little hard is those rules can be used in so many places.

Raw SQL to select unused product streams:

with used as (

	select
		p.id
	from product_stream p
		left join product_stream_translation pst on p.id =pst.product_stream_id 
	where
		p.id in (select product_stream_id from category)
		or p.id in (select product_stream_id from product_export)
		or p.id in (select product_stream_id from product_cross_selling)
		or p.id in (select unhex(json_unquote(json_extract(rc.value, '$[0]'))) from rule_condition rc where rc.`type` = 'cartLineItemInProductStream') # TODO: There can be multiple Streams chosen
		or p.id in (select unhex(json_unquote(json_extract(cst.config, '$.products.value'))) from cms_slot cs inner join cms_slot_translation cst on cs.id = cst.cms_slot_id and cs.version_id = cst.cms_slot_version_id and cs.`type` = 'product-slider' and json_unquote(json_extract(cst.config, '$.products.source')) = 'product_stream')

)

select
	ps.id, pst.name, ps.invalid, ps.api_filter, pst.description
from product_stream ps
	inner join product_stream_translation pst on ps.id = pst.product_stream_id 
	inner join `language` l on pst.language_id = l.id and l.name = 'Deutsch'
where
	ps.id not in (select * from used)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant