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

Let active record format the Time #146

Merged
merged 2 commits into from
Dec 1, 2021
Merged

Let active record format the Time #146

merged 2 commits into from
Dec 1, 2021

Conversation

craigmcnamara
Copy link
Collaborator

@craigmcnamara craigmcnamara commented Dec 1, 2021

Don't pre-format the Time passed to the unexpired scope. This allows the ActiveRecord adapter to format the date according to it's own needs.

Maybe addresses #144 problems, but it seems like they probably have an incorrectly configured application.

Before SQL:

D, [2021-11-30T22:51:27.785105 #91313] DEBUG -- :   Shortener::ShortenedUrl Exists? (0.1ms)  SELECT 1 AS one FROM "shortened_urls" WHERE ("shortened_urls"."expires_at" IS NULL OR "shortened_urls"."expires_at" > '2021-12-01 06:51:27') AND "shortened_urls"."id" = ? LIMIT ?  [["id", 279], ["LIMIT", 1]]
D, [2021-11-30T22:51:27.785193 #91313] DEBUG -- :   ↳ activerecord (6.1.4.1) lib/active_record/log_subscriber.rb:119:in `debug'
D, [2021-11-30T22:51:27.785447 #91313] DEBUG -- :   Shortener::ShortenedUrl Exists? (0.1ms)  SELECT 1 AS one FROM "shortened_urls" WHERE ("shortened_urls"."expires_at" IS NULL OR "shortened_urls"."expires_at" > '2021-12-01 06:51:27') AND "shortened_urls"."id" = ? LIMIT ?  [["id", 278], ["LIMIT", 1]]
D, [2021-11-30T22:51:27.785537 #91313] DEBUG -- :   ↳ activerecord (6.1.4.1) lib/active_record/log_subscriber.rb:119:in `debug'
D, [2021-11-30T22:51:27.785770 #91313] DEBUG -- :   Shortener::ShortenedUrl Exists? (0.0ms)  SELECT 1 AS one FROM "shortened_urls" WHERE ("shortened_urls"."expires_at" IS NULL OR "shortened_urls"."expires_at" > '2021-12-01 06:51:27') AND "shortened_urls"."id" = ? LIMIT ?  [["id", 277], ["LIMIT", 1]]
D, [2021-11-30T22:51:27.785859 #91313] DEBUG -- :   ↳ activerecord (6.1.4.1) lib/active_record/log_subscriber.rb:119:in `debug'
D, [2021-11-30T22:51:27.786130 #91313] DEBUG -- :   Shortener::ShortenedUrl Load (0.2ms)  SELECT "shortened_urls".* FROM "shortened_urls" WHERE ("shortened_urls"."expires_at" IS NULL OR "shortened_urls"."expires_at" > '2021-12-01 06:51:27')

After SQL:

D, [2021-11-30T22:51:55.141241 #91931] DEBUG -- :   Shortener::ShortenedUrl Exists? (0.1ms)  SELECT 1 AS one FROM "shortened_urls" WHERE ("shortened_urls"."expires_at" IS NULL OR "shortened_urls"."expires_at" > '2021-12-01 06:51:55.136749') AND "shortened_urls"."id" = ? LIMIT ?  [["id", 285], ["LIMIT", 1]]
D, [2021-11-30T22:51:55.141333 #91931] DEBUG -- :   ↳ activerecord (6.1.4.1) lib/active_record/log_subscriber.rb:119:in `debug'
D, [2021-11-30T22:51:55.141578 #91931] DEBUG -- :   Shortener::ShortenedUrl Exists? (0.0ms)  SELECT 1 AS one FROM "shortened_urls" WHERE ("shortened_urls"."expires_at" IS NULL OR "shortened_urls"."expires_at" > '2021-12-01 06:51:55.136749') AND "shortened_urls"."id" = ? LIMIT ?  [["id", 284], ["LIMIT", 1]]
D, [2021-11-30T22:51:55.141661 #91931] DEBUG -- :   ↳ activerecord (6.1.4.1) lib/active_record/log_subscriber.rb:119:in `debug'
D, [2021-11-30T22:51:55.141889 #91931] DEBUG -- :   Shortener::ShortenedUrl Exists? (0.0ms)  SELECT 1 AS one FROM "shortened_urls" WHERE ("shortened_urls"."expires_at" IS NULL OR "shortened_urls"."expires_at" > '2021-12-01 06:51:55.136749') AND "shortened_urls"."id" = ? LIMIT ?  [["id", 283], ["LIMIT", 1]]
D, [2021-11-30T22:51:55.141977 #91931] DEBUG -- :   ↳ activerecord (6.1.4.1) lib/active_record/log_subscriber.rb:119:in `debug'
D, [2021-11-30T22:51:55.142271 #91931] DEBUG -- :   Shortener::ShortenedUrl Load (0.2ms)  SELECT "shortened_urls".* FROM "shortened_urls" WHERE ("shortened_urls"."expires_at" IS NULL OR "shortened_urls"."expires_at" > '2021-12-01 06:51:55.136749')

@craigmcnamara
Copy link
Collaborator Author

@fschwahn @jpmcgrath Hey, I submitted some patches a while back. I was just dropping in to check on the state of things because I'm probably installing Shortener in my latest app tomorrow. I responded to some pull requests, I hope I'm not over stepping. Things are looking great still. Thanks for the hard work.

Copy link
Collaborator

@fschwahn fschwahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change, we should let activerecord do its thing 👍

@fschwahn
Copy link
Collaborator

fschwahn commented Dec 1, 2021

It seems CI is broken due to https://travis-ci.org/ being abandoned in favor of https://www.travis-ci.com/. @jpmcgrath I think that's something only you can fix.

@fschwahn
Copy link
Collaborator

fschwahn commented Dec 1, 2021

@craigmcnamara I want ahead and integrated github actions. Can you rebase the PR?

Don't pre-format the Time passed to the `unexpired` scope. This allows the ActiveRecord adapter to format the date according to it's own needs.
@craigmcnamara craigmcnamara merged commit 630be48 into develop Dec 1, 2021
@fschwahn fschwahn deleted the fix-expires-at branch April 14, 2022 11:35
@fschwahn
Copy link
Collaborator

@jpmcgrath could you maybe release a new version? This is causing deprecation warnings on rails 7.

@jpmcgrath
Copy link
Owner

Yes, I can release a new version soon. Thanks for the prompt.

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.

3 participants