mod/01_history/set/all/content_history.rb in card-1.18.3 vs mod/01_history/set/all/content_history.rb in card-1.18.4
- old
+ new
@@ -26,24 +26,23 @@
.card_changes.build(field: :db_content, value: content)
end
end
def last_change_on field, opts={}
- where_sql = 'card_actions.card_id = :card_id AND field = :field '
- where_sql += 'AND (draft is not true) ' unless opts[:including_drafts]
- where_sql += if opts[:before]
- 'AND card_action_id < :action_id'
- elsif opts[:not_after]
- 'AND card_action_id <= :action_id'
- else
- ''
- end
+ where_sql = 'card_actions.card_id = :card_id AND field = :field'
+ where_sql += ' AND (draft is not true)' unless opts[:including_drafts]
+ if opts[:before]
+ where_sql += ' AND card_action_id < :action_id'
+ elsif opts[:not_after]
+ where_sql += ' AND card_action_id <= :action_id'
+ end
action_arg = opts[:before] || opts[:not_after]
action_id = action_arg.is_a?(Card::Action) ? action_arg.id : action_arg
- field_index = Card::TRACKED_FIELDS.index(field.to_s)
Change.joins(:action).where(
- where_sql, card_id: id, field: field_index, action_id: action_id
+ where_sql, card_id: id,
+ field: Card::Change.field_index(field),
+ action_id: action_id
).order(:id).last
end
def selected_action_id
@selected_action_id || (@current_action && @current_action.id) ||