mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Improve bookmark modal on mobile and bookmark sync rake task (#9221)
* Improve the bookmark mobile on modal so it doesn't go all the way to the edge and the custom datetime input is easier to use * Improve the rake task for syncing so it does not error for topics that no longer exist and batches 2000 inserts at a time, clearing the array each time
This commit is contained in:
parent
e50abe1317
commit
16799da580
@ -38,14 +38,14 @@
|
|||||||
{{tap-tile icon="ban" text=(I18n "bookmarks.reminders.none") tileId=reminderTypes.NONE activeTile=grid.activeTile onChange=(action "selectReminderType")}}
|
{{tap-tile icon="ban" text=(I18n "bookmarks.reminders.none") tileId=reminderTypes.NONE activeTile=grid.activeTile onChange=(action "selectReminderType")}}
|
||||||
{{/tap-tile-grid}}
|
{{/tap-tile-grid}}
|
||||||
{{#if customDateTimeSelected}}
|
{{#if customDateTimeSelected}}
|
||||||
<div class="control-group">
|
<div class="control-group custom-date-time-wrap">
|
||||||
{{d-icon "calendar-alt"}}
|
{{d-icon "calendar-alt"}}
|
||||||
{{date-picker-future
|
{{date-picker-future
|
||||||
value=customReminderDate
|
value=customReminderDate
|
||||||
onSelect=(action (mut customReminderDate))
|
onSelect=(action (mut customReminderDate))
|
||||||
}}
|
}}
|
||||||
{{d-icon "far-clock"}}
|
{{d-icon "far-clock"}}
|
||||||
{{input placeholder="--:--" type="time" value=customReminderTime}}
|
{{input placeholder="--:--" type="time" class="time-input" value=customReminderTime}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
.bookmark-with-reminder.modal {
|
.bookmark-with-reminder.modal {
|
||||||
|
.modal-inner-container {
|
||||||
|
max-width: 95%;
|
||||||
|
}
|
||||||
.modal-body {
|
.modal-body {
|
||||||
max-width: 410px;
|
max-width: 410px;
|
||||||
min-width: 380px;
|
min-width: 380px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
.control-label {
|
.control-label {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
@ -11,4 +15,26 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.custom-date-time-wrap {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: baseline;
|
||||||
|
|
||||||
|
.svg-icon {
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
.date-picker {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-input {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ task "bookmarks:sync_to_table", [:sync_limit] => :environment do |_t, args|
|
|||||||
.joins(:post)
|
.joins(:post)
|
||||||
.where(deleted_at: nil)
|
.where(deleted_at: nil)
|
||||||
.joins('LEFT JOIN bookmarks ON bookmarks.post_id = post_actions.post_id AND bookmarks.user_id = post_actions.user_id')
|
.joins('LEFT JOIN bookmarks ON bookmarks.post_id = post_actions.post_id AND bookmarks.user_id = post_actions.user_id')
|
||||||
|
.joins('INNER JOIN topics ON topics.id = posts.topic_id')
|
||||||
.where('bookmarks.id IS NULL')
|
.where('bookmarks.id IS NULL')
|
||||||
|
|
||||||
# if sync_limit is provided as an argument this will cap
|
# if sync_limit is provided as an argument this will cap
|
||||||
@ -27,11 +28,13 @@ task "bookmarks:sync_to_table", [:sync_limit] => :environment do |_t, args|
|
|||||||
end
|
end
|
||||||
|
|
||||||
post_action_bookmark_count = post_action_bookmarks.count('post_actions.id')
|
post_action_bookmark_count = post_action_bookmarks.count('post_actions.id')
|
||||||
bookmarks_to_create = []
|
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
|
post_action_bookmarks.find_each(batch_size: 2000) do |pab|
|
||||||
|
# clear at start of each batch to only insert X at a time
|
||||||
|
bookmarks_to_create = []
|
||||||
|
|
||||||
Bookmark.transaction do
|
Bookmark.transaction do
|
||||||
post_action_bookmarks.find_each(batch_size: 1000) do |pab|
|
|
||||||
RakeHelpers.print_status_with_label("Creating post new bookmarks.......", i, post_action_bookmark_count)
|
RakeHelpers.print_status_with_label("Creating post new bookmarks.......", i, post_action_bookmark_count)
|
||||||
now = Time.zone.now
|
now = Time.zone.now
|
||||||
bookmarks_to_create << {
|
bookmarks_to_create << {
|
||||||
@ -43,7 +46,6 @@ task "bookmarks:sync_to_table", [:sync_limit] => :environment do |_t, args|
|
|||||||
}
|
}
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
end
|
|
||||||
|
|
||||||
# this will ignore conflicts in the bookmarks table so
|
# this will ignore conflicts in the bookmarks table so
|
||||||
# if the user already has a post bookmarked in the new way,
|
# if the user already has a post bookmarked in the new way,
|
||||||
@ -54,6 +56,7 @@ task "bookmarks:sync_to_table", [:sync_limit] => :environment do |_t, args|
|
|||||||
# won't blow up
|
# won't blow up
|
||||||
Bookmark.insert_all(bookmarks_to_create)
|
Bookmark.insert_all(bookmarks_to_create)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
RakeHelpers.print_status_with_label("Bookmark creation complete! ", i, post_action_bookmark_count)
|
RakeHelpers.print_status_with_label("Bookmark creation complete! ", i, post_action_bookmark_count)
|
||||||
puts ""
|
puts ""
|
||||||
|
@ -43,6 +43,17 @@ RSpec.describe "bookmarks tasks" do
|
|||||||
expect(Bookmark.all.count).to eq(1)
|
expect(Bookmark.all.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "skips post actions where the post topic no longer exists and does not error" do
|
||||||
|
post1.topic.delete
|
||||||
|
post1.reload
|
||||||
|
expect { invoke_task }.not_to raise_error
|
||||||
|
end
|
||||||
|
|
||||||
|
it "skips post actions where the post no longer exists and does not error" do
|
||||||
|
post1.delete
|
||||||
|
expect { invoke_task }.not_to raise_error
|
||||||
|
end
|
||||||
|
|
||||||
def create_post_actions_and_existing_bookmarks
|
def create_post_actions_and_existing_bookmarks
|
||||||
Fabricate(:post_action, user: user1, post: post1, post_action_type_id: PostActionType.types[:bookmark])
|
Fabricate(:post_action, user: user1, post: post1, post_action_type_id: PostActionType.types[:bookmark])
|
||||||
Fabricate(:post_action, user: user2, post: post2, post_action_type_id: PostActionType.types[:bookmark])
|
Fabricate(:post_action, user: user2, post: post2, post_action_type_id: PostActionType.types[:bookmark])
|
||||||
|
Loading…
Reference in New Issue
Block a user