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

keep inserted_at value to the original value #36

Merged
merged 8 commits into from
Feb 6, 2019
Merged

Conversation

SimonLab
Copy link
Member

@SimonLab SimonLab commented Feb 4, 2019

ref: #30
Define inserted_at value to be the timestamp of the first item inserted

@SimonLab SimonLab self-assigned this Feb 4, 2019
@SimonLab SimonLab requested a review from Danwhy February 4, 2019 12:30
@SimonLab SimonLab assigned Danwhy and unassigned SimonLab Feb 4, 2019
Copy link
Member

@Danwhy Danwhy left a comment

Choose a reason for hiding this comment

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

This is a good way to get the inserted_at timestamp for all items, but I'm not sure we want it to be part of the all function; making two Repo.all calls, plus mapping over the results could really slow down the query.

I feel like it would be better to override the default inserted_at timestamp when we update an item, retaining it from the last row.

We could use the code you've written here, but I think using it only once, as part of a migration script which updates the inserted_at of the most recent items would be better.

@SimonLab
Copy link
Member Author

SimonLab commented Feb 4, 2019

@Danwhy makes sense 👍

@SimonLab
Copy link
Member Author

SimonLab commented Feb 5, 2019

@Danwhy the insert function should now keep the first inserted_at value. I've also updated the functions to sort by updated_at instead of inserterd_at to make sure to get the newest item.

Copy link
Member

@Danwhy Danwhy left a comment

Choose a reason for hiding this comment

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

Looks good, just one small point

mix.exs Outdated
@@ -4,7 +4,7 @@ defmodule Alog.MixProject do
def project do
[
app: :alog,
version: "0.4.2",
version: "0.4.3",
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be 0.5.0 now, as we've changed the behaviour of the module

Copy link
Member Author

@SimonLab SimonLab Feb 5, 2019

Choose a reason for hiding this comment

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

I wasn't sure about the version. For me it's a patch fix as the API hasn't changed and I don't think this PR add a new functionality, I see keeping the inserted_at value as a bug fix

MAJOR version when you make incompatible API changes,
MINOR version when you add functionality in a backwards-compatible manner, and
PATCH version when you make backwards-compatible bug fixes.

but happy to to update to 0.5.0 if you think the logic of the code is different 👍 , let me know what you prefer

Copy link
Member

Choose a reason for hiding this comment

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

I see how this could be considered a bug, but I think it changes enough that it could introduce unexpected errors into code that uses it, eg. someone could have been using inserted_by to get the most recent items in their database, and now that won't work the same.

I think just to be safe we should bump to 0.5.0

https://xkcd.com/1172/

bump version to 0.5.0
.travis.yml Outdated
otp_release:
- 20.2.4
env:
- MIX_ENV=test
Copy link
Member

@samhstn samhstn Feb 5, 2019

Choose a reason for hiding this comment

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

don't think you need this env, you've already written it below

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, thanks @samhstn 👍

remove duplicate env value in travis.yml file
Copy link
Member

@Danwhy Danwhy left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @SimonLab

@Danwhy Danwhy assigned nelsonic and unassigned Danwhy Feb 5, 2019
@@ -0,0 +1,18 @@
language: elixir
Copy link
Member

Choose a reason for hiding this comment

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

🥇

Copy link
Member

@nelsonic nelsonic left a comment

Choose a reason for hiding this comment

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

@SimonLab great work, thanks! 👍

@nelsonic nelsonic merged commit 7161590 into master Feb 6, 2019
@nelsonic nelsonic deleted the inserted_at-value branch February 6, 2019 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants