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

Refactor the Cleanup query #1426

Closed
Tracked by #1415
eerison opened this issue Jul 1, 2022 · 15 comments
Closed
Tracked by #1415

Refactor the Cleanup query #1426

eerison opened this issue Jul 1, 2022 · 15 comments
Labels

Comments

@eerison
Copy link
Contributor

eerison commented Jul 1, 2022

Refactor the cleanup query

the clean up code uses this query: https://github.com/sonata-project/SonataPageBundle/blob/3.x/src/Entity/SnapshotManager.php#L228-L288, and we should refactor this to DQL query, maybe this can help: https://stackoverflow.com/questions/6637506/doing-a-where-in-subquery-in-doctrine-2

should be really good if you can test this using mysql and oracle database. but if you have problems to test oracle post the comment here.

@eerison eerison added the feature label Jul 1, 2022
@eerison
Copy link
Contributor Author

eerison commented Jul 1, 2022

This ticket is not a block for #1415 , but should be really good if we could refactor this

@eerison
Copy link
Contributor Author

eerison commented Jul 1, 2022

@VincentLanglet

make sense to add this into roadmap 4.0 ?

@VincentLanglet
Copy link
Member

make sense to add this into roadmap 4.0 ?

It does not seem needed to me, since this change will be BC.
So it can be done before or after the 4.0 release, can't it ?

@eerison
Copy link
Contributor Author

eerison commented Jul 1, 2022

it is not a BC, But I thought that we're using the roadmap to track the tickets that should be in release 4.0!

I know it's not a must, it's just a wish :P

@VincentLanglet
Copy link
Member

it is not a BC, But I thought that we're using the roadmap to track the tickets that should be in release 4.0!

I try to track the tickets that we need for the 4.0.

I know it's not a must, it's just a wish :P

It's still a good suggestion. But not a blocker for 4.0.
There is already so much to do, the question is "What are the minimal changes needed in order to release a bundle compatible with SonataAdmin4 and Symfony5". ;)

@eerison
Copy link
Contributor Author

eerison commented Jul 1, 2022

What are the minimal changes needed in order to release a bundle compatible with SonataAdmin4 and Symfony5

Good question :P, I'll try to check the deprecations that I got in test and see if I can create some ticket to fix them.

@Hanmac
Copy link
Contributor

Hanmac commented Jul 11, 2022

if it is okay i can look at the queries too

@Hanmac
Copy link
Contributor

Hanmac commented Jul 11, 2022

i didn't had time to debug yet, but does this look like a good replacement for the enable snapshots query?

        $qb = $this->getRepository()->createQueryBuilder('s');
        $expr = $qb->expr();
        $qb->update()
            ->set('publication_date_end', $date->format('Y-m-d H:i:s'))
            ->where($expr->notIn('id', $snapshotIds))
            ->andWhere($expr->in('page_id', $pageIds))
            ->andWhere($expr->isNull('publication_date_end'))
            ->getQuery()->execute();

for this query?

        // @todo: strange sql and low-level pdo usage: use dql or qb
        $sql = sprintf(
            "UPDATE %s SET publication_date_end = '%s' WHERE id NOT IN(%s) AND page_id IN (%s) and publication_date_end IS NULL",
            $this->getTableName(),
            $date->format('Y-m-d H:i:s'),
            implode(',', $snapshotIds),
            implode(',', $pageIds)
        );

@VincentLanglet
Copy link
Member

Seems ok to me. Pr is welcome :)

@Hanmac
Copy link
Contributor

Hanmac commented Jul 11, 2022

are such Query changes 3.x or 4.x stuff?

@VincentLanglet
Copy link
Member

VincentLanglet commented Jul 11, 2022

It's supposed to be BC so 3.x I would say

@Hanmac
Copy link
Contributor

Hanmac commented Jul 12, 2022

ugh the current test cases are making problems because i seem to can't to make the query builder execute with big chunk of meta data.

i probably need to make this into a KernelTestCase and let it run against test database

@Hanmac
Copy link
Contributor

Hanmac commented Jul 12, 2022

first try: #1446

i need more testcases for this

@VincentLanglet
Copy link
Member

Now #1446 is merged, can we close this issue @eerison ?

@eerison
Copy link
Contributor Author

eerison commented Jul 18, 2022

yes we can :) 🥳

@eerison eerison closed this as completed Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants