Skip to content
New issue

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

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

Already on GitHub? # to your account

Lazy loading in dev breaks things #16

Open
ideasasylum opened this issue Sep 8, 2023 · 0 comments
Open

Lazy loading in dev breaks things #16

ideasasylum opened this issue Sep 8, 2023 · 0 comments
Assignees
Labels
DX Developer experience

Comments

@ideasasylum
Copy link
Contributor

ideasasylum commented Sep 8, 2023

class User < ApplicationRecord
  counter ProductsCounter
end

class ProductsCounter < Counter::Definition
  count :products
end

I think there's a problem in development if the ProductsCounter class is loaded before the User class since the counter doesn't know it's associated with User -> Products. It's just given the association not the parent model. This can lead to an error or the wrong name being used (I can't remember, one or the other). I've seen this happen in very isolated tests or the Rails console.

Some ideas:

  • Put all counters into their own directory
  • Counters need to specify the parent model and association (unless they are manual counters)
    • if we did that, is it necessary to specify counter ProductsCounter in the User model?
    • If not, is that a weird thing since Rails devs probably expect something to appear there
    • if we want something there, how should we restructure the counter definitions?
@ideasasylum ideasasylum converted this from a draft issue Sep 8, 2023
@ideasasylum ideasasylum added the DX Developer experience label Sep 8, 2023
@ideasasylum ideasasylum moved this from To do to Considering in Counters prototype Sep 8, 2023
@ideasasylum ideasasylum self-assigned this Jan 4, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
DX Developer experience
Projects
Status: Noodling on
Development

No branches or pull requests

1 participant