-
Notifications
You must be signed in to change notification settings - Fork 3
Added a comand for checking if user email exist in api and MW user tables #1031
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
base: main
Are you sure you want to change the base?
Conversation
tarrow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good direction to start in. Definitely a bit different from the raw string matching in the ticket but seems a fine idea to me. I like the test. I guess you're also working on one for Wiki data too?
One comment I added for myself to worry about because I have some vague memory about these connections being a bit odd when we set them like this but I need to do some research
|
|
||
| $manager = app()->db; | ||
| $manager->purge('mw'); | ||
| $mwConn = $manager->connection('mw'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Tom to look up:
- do we also need to undo this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leaving this open for @tarrow
AndrewKostka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it out and it works for me locally. I added a few suggestions for ways we could reduce the number of queries if we run into any performance issues. However, the benefits only kick in for larger email lists. I don't suspect we'll use this feature that heavily, so I'd ignore these suggestions for now.
| $pdo = $this->db->connection('mw')->getPdo(); | ||
|
|
||
| $mwDatabases = $pdo | ||
| ->query("SHOW DATABASES LIKE 'mwdb_%'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could choose to run this query only once per command execution.
| } | ||
|
|
||
| private function findUserTable(PDO $pdo, string $dbName): ?string { | ||
| $stmt = $pdo->prepare(" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also choose to run this query only once per command execution.
| $stmt = $pdo->prepare(" | ||
| SELECT 1 | ||
| FROM {$dbName}.{$table} | ||
| WHERE user_email = :email |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could check all emails in bulk using one query.
Bug: T410856