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

Not persisting hours after creating them with the in-memory repository #4

Open
msamoylov opened this issue Sep 28, 2020 · 3 comments
Open

Comments

@msamoylov
Copy link

msamoylov commented Sep 28, 2020

So, you're creating a new Hour, but returning it immediately without storing it in the map.

return m.hourFactory.NewNotAvailableHour(hourTime)

It looks like ok will be always false.

Am I missing something here?

@roblaszczak
Copy link
Member

That should be documented better 😉.

In general, the idea is, that the repository should be independent of the database, but be rather some domain concept. By example it will be probably more clear:

In practice (not in the database, in reality) hour exists, even if it was not persisted. So for example, if we didn't persist 14:00 it exists anyway and is available for training. So that's why it is not persisted in GetHour.

If we want to persist it, we need to explicitly call UpdateHour. This is also how it works for all other implementations.

Does it make sense for you?

@msamoylov
Copy link
Author

What I was saying, is that you're just returning a newly created hour without putting it to the map.

return m.hourFactory.NewNotAvailableHour(hourTime)

This should be IMO:

        currentHour, err := m.hourFactory.NewNotAvailableHour(hourTime) 
        // Handle error, skipped
        m.hours[hourTime] = *currentHour

Otherwise your in-memory storage doesn't make much sense.

@m110
Copy link
Member

m110 commented Nov 10, 2020

@msamoylov It's persisted in the UpdateHour method:

The result of GetHour is returned to the frontend application, which shows the hour as empty, if it's not filled in the database. The user can then click a button to fill it.

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

No branches or pull requests

3 participants