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

Fix logic in "last used at per application" oauth token list #32912

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

mjankowski
Copy link
Contributor

Background: #25060 (review)

The resulting query winds up looking like...

Doorkeeper::AccessToken Maximum (1.5ms)  SELECT MAX("oauth_access_tokens"."last_used_at") AS "maximum_last_used_at", "oauth_access_tokens"."application_id" AS "oauth_access_tokens_application_id" FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."resource_owner_id" = $1 AND "oauth_access_tokens"."last_used_at" IS NOT NULL GROUP BY "oauth_access_tokens"."application_id"  [["resource_owner_id", 1259]]

...which gives us the id-indexed hash pointing to latest date for each application.

Future improvements here:

  • At minium, we could declare an association for user<>token which could be used here and in a few other spots where we are fully building these types of queries
  • In addition to that, we could contemplate something like Add Doorkeeper::Application.webapp helper #31042 (comment) in which case those new models could also have scopes for the "last used not nil" portion of this

I think this spec covers at least the most basic scenarios, but let me know if I missed an edge case or some portion of what this is doing.

@Gargron Gargron enabled auto-merge November 15, 2024 15:50
@Gargron Gargron added this pull request to the merge queue Nov 15, 2024
Merged via the queue into mastodon:main with commit 3191090 Nov 15, 2024
27 checks passed
@mjankowski mjankowski deleted the authorized-apps-query branch November 15, 2024 16:04
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

Successfully merging this pull request may close these issues.

2 participants