-
Notifications
You must be signed in to change notification settings - Fork 555
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
feat: store created and modified time separately on database for bookmarks #896
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #896 +/- ##
==========================================
+ Coverage 34.73% 35.11% +0.38%
==========================================
Files 61 61
Lines 4054 4061 +7
==========================================
+ Hits 1408 1426 +18
+ Misses 2424 2413 -11
Partials 222 222 ☔ View full report in Codecov by Sentry. |
Hey @Monirzadeh is this ready for review? I see items pending. A side comment for me, would it me much effort renaming the |
mysql is not ready yet ok i will change names column to |
Let me know if you get stuck with this, I can take a look if you want.
Leave the old API as is, we will use the new field in the new API. |
RENAME COLUMN modified to created_at; | ||
|
||
ALTER TABLE bookmark | ||
ADD COLUMN modified_at TEXT NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified_at
is TEXT NULL
not
modified_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
dose it make any problem?
Hi @fmartingr
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Monirzadeh, good job as ususal. I've left a few comments around for changes.
Also, I'm missing tests for:
- Ensuring created_at time is set correctly when creating
- Ensuring modified_at time is set correctly when updating
- Ensuring created_at filter works properly
- Ensuring modified_at filter works properly
Let me know if you need help with any of those.
Thank you!
…ated and modified is not in same day
Forgot to check, but we should probably add indexes in the datetime fields since we are going to rely on those heavily on results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @Monirzadeh !! This is starting to look real good 👏
I have left some requests around. Most are just style things but there are some concerns around. Please take a look and let me know what you think.
internal/model/bookmark.go
Outdated
@@ -14,7 +14,8 @@ type BookmarkDTO struct { | |||
Excerpt string `db:"excerpt" json:"excerpt"` | |||
Author string `db:"author" json:"author"` | |||
Public int `db:"public" json:"public"` | |||
Modified string `db:"modified" json:"modified"` | |||
Created string `db:"created_at" json:"created"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this fields CreatedAt
/ ModifiedAt
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json:"created" should be json:"createdAt"
or json:"created_at"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Golang code, CamelCase
, for JSON snake_case
. Though honestly we could just match everything to the same CamelCase
in golang and avoid writting so many json annotations. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personalty i am not against none of them. currently we have both of them in json (like imageURL
, hasContent
or snake case like create_archive
and create_ebook
)
i am worried about shiori app backward compatibility (if i am not wrong it work with 1.5.5)
as i see there is not specific suggestion in json but usualy use snake_case
@DesarrolloAntonio what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DesarrolloAntonio what do you think?
Regarding backward compatibility in the Shiori app, I have seen that there is an option to set one or more alternative names. I have never tried it, but theoretically, it should work.`
@SerializedName("createdAt", alternate = ["created_at"])
val createdAt: String?,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
So @fmartingr if you like camelCase
can go fot that
Beside camelCase
or snake_case
I think it better to done that in separate PR so later we can refrence that in future issue related to API if anybody ask.
I already use camelCase
in this PR
internal/view/content.html
Outdated
@@ -38,6 +37,9 @@ | |||
<div id="content" dir="auto" v-pre> | |||
$$.HTML$$ | |||
</div> | |||
<div id="footer"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a <footer>
element rather than a div#footer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently we have footer for two place Version
in login page and here.
do you want two diffrent footer style?
.footer
and another content-footer
?
shiori/internal/view/assets/less/common.less
Lines 8 to 10 in 9aa8332
footer { | |
color: var(--color); | |
} |
and
#footer {
width: 100%;
padding: 20px;
max-width: 840px;
margin-bottom: 16px;
background-color: var(--contentBg);
border: 1px solid var(--border);
display: flex;
flex-flow: column;
align-items: center;
#metadata {
display: flex;
flex-flow: row wrap;
text-align: center;
font-size: 16px;
color: var(--colorLink);
&:nth-child(1) {
justify-content: flex-start;
}
&:nth-child(2) {
justify-content: flex-end;
}
&[v-cloak] {
visibility: hidden;
}
}
#title {
padding: 8px 0;
grid-column-start: 1;
grid-column-end: -1;
font-size: 36px;
font-weight: 700;
word-break: break-word;
hyphens: none;
text-align: center;
}
#links {
display: flex;
flex-flow: row wrap;
a {
padding: 0 4px;
color: var(--color);
text-decoration: underline;
&:hover,
&:focus {
color: var(--main);
}
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is 171cea9 what you want?
flex-flow: column; | ||
align-items: center; | ||
|
||
#metadata { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using IDs for styling, use classes instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it what you want? 19b9221
i remove some duplicate style and i can review other part and change them to class too. at least in content page.
the metadata color not much readable in light mode (look at the color of added time in light mode)
i test color like normal text (black) but not good looking. i thinking about make this a little darker in light mode. any suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal/database/database_test.go
Outdated
func testModifiedTimeUpdate(t *testing.T, db DB) { | ||
ctx := context.TODO() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this test uses time.Sleep
let's run it in parallel to avoid blocking other tests.
func testModifiedTimeUpdate(t *testing.T, db DB) { | |
ctx := context.TODO() | |
func testModifiedTimeUpdate(t *testing.T, db DB) { | |
t.Parallel() | |
ctx := context.TODO() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't see those error in local system that show me that here 9c02e7b for example in golangci-lint
internal/database/database_test.go
Outdated
func testModifiedAndCreateTimeFilter(t *testing.T, db DB) { | ||
ctx := context.TODO() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this test uses time.Sleep
let's run it in parallel to avoid blocking other tests.
func testModifiedAndCreateTimeFilter(t *testing.T, db DB) { | |
ctx := context.TODO() | |
func testModifiedAndCreateTimeFilter(t *testing.T, db DB) { | |
t.Parallel() | |
ctx := context.TODO() |
Co-authored-by: Felipe Martin <[email protected]>
@fmartingr |
Ok I was thinking that we received a new empty database on each run but right now that's only true for SQLite (not for Postgres/Mysql). Let's remove the // TODO: Consider using `t.Parallel()` once we have automated database tests spawning databases using testcontainers. |
this PR should done two things:
created
time to the databasemodified
update if write new content in an exist bookmark.any place you will done change in any aspect of bookmark (new archive,content,epub,tags,etc)
in future if we want to update modified time any place in code just set
book.modified = ""
shiori automatically will update modified time.TODO:
modfied_at
same as other database mariadb update modified time when row change that not possible in other database this change in this PR and all use same method now.