mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 06:56:01 +08:00
DEV: remove exec_sql and replace with mini_sql
Introduce new patterns for direct sql that are safe and fast. MiniSql is not prone to memory bloat that can happen with direct PG usage. It also has an extremely fast materializer and very a convenient API - DB.exec(sql, *params) => runs sql returns row count - DB.query(sql, *params) => runs sql returns usable objects (not a hash) - DB.query_hash(sql, *params) => runs sql returns an array of hashes - DB.query_single(sql, *params) => runs sql and returns a flat one dimensional array - DB.build(sql) => returns a sql builder See more at: https://github.com/discourse/mini_sql
This commit is contained in:
@ -311,8 +311,10 @@ describe TopicUser do
|
||||
it 'should update tracking state when you reply' do
|
||||
new_user.user_option.update_column(:notification_level_when_replying, 3)
|
||||
post_creator.create
|
||||
TopicUser.exec_sql("UPDATE topic_users set notification_level=2
|
||||
WHERE topic_id = :topic_id AND user_id = :user_id", topic_id: topic_new_user.topic_id, user_id: topic_new_user.user_id)
|
||||
DB.exec("UPDATE topic_users set notification_level=2
|
||||
WHERE topic_id = :topic_id AND user_id = :user_id",
|
||||
topic_id: topic_new_user.topic_id, user_id: topic_new_user.user_id)
|
||||
|
||||
TopicUser.auto_notification(topic_new_user.user_id, topic_new_user.topic_id, TopicUser.notification_reasons[:created_post], TopicUser.notification_levels[:watching])
|
||||
|
||||
tu = TopicUser.find_by(user_id: topic_new_user.user_id, topic_id: topic_new_user.topic_id)
|
||||
@ -322,7 +324,7 @@ describe TopicUser do
|
||||
it 'should not update tracking state when you reply' do
|
||||
new_user.user_option.update_column(:notification_level_when_replying, 3)
|
||||
post_creator.create
|
||||
TopicUser.exec_sql("UPDATE topic_users set notification_level=3
|
||||
DB.exec("UPDATE topic_users set notification_level=3
|
||||
WHERE topic_id = :topic_id AND user_id = :user_id", topic_id: topic_new_user.topic_id, user_id: topic_new_user.user_id)
|
||||
TopicUser.auto_notification(topic_new_user.user_id, topic_new_user.topic_id, TopicUser.notification_reasons[:created_post], TopicUser.notification_levels[:tracking])
|
||||
|
||||
@ -333,7 +335,7 @@ describe TopicUser do
|
||||
it 'should not update tracking state when state manually set to normal you reply' do
|
||||
new_user.user_option.update_column(:notification_level_when_replying, 3)
|
||||
post_creator.create
|
||||
TopicUser.exec_sql("UPDATE topic_users set notification_level=1
|
||||
DB.exec("UPDATE topic_users set notification_level=1
|
||||
WHERE topic_id = :topic_id AND user_id = :user_id", topic_id: topic_new_user.topic_id, user_id: topic_new_user.user_id)
|
||||
TopicUser.auto_notification(topic_new_user.user_id, topic_new_user.topic_id, TopicUser.notification_reasons[:created_post], TopicUser.notification_levels[:tracking])
|
||||
|
||||
@ -344,7 +346,7 @@ describe TopicUser do
|
||||
it 'should not update tracking state when state manually set to muted you reply' do
|
||||
new_user.user_option.update_column(:notification_level_when_replying, 3)
|
||||
post_creator.create
|
||||
TopicUser.exec_sql("UPDATE topic_users set notification_level=0
|
||||
DB.exec("UPDATE topic_users set notification_level=0
|
||||
WHERE topic_id = :topic_id AND user_id = :user_id", topic_id: topic_new_user.topic_id, user_id: topic_new_user.user_id)
|
||||
TopicUser.auto_notification(topic_new_user.user_id, topic_new_user.topic_id, TopicUser.notification_reasons[:created_post], TopicUser.notification_levels[:tracking])
|
||||
|
||||
@ -417,7 +419,7 @@ describe TopicUser do
|
||||
p2 = Fabricate(:post, user: p1.user, topic: p1.topic, post_number: 2)
|
||||
p1.topic.notifier.watch_topic!(p1.user_id)
|
||||
|
||||
TopicUser.exec_sql("UPDATE topic_users set highest_seen_post_number=1, last_read_post_number=0
|
||||
DB.exec("UPDATE topic_users set highest_seen_post_number=1, last_read_post_number=0
|
||||
WHERE topic_id = :topic_id AND user_id = :user_id", topic_id: p1.topic_id, user_id: p1.user_id)
|
||||
|
||||
[p1, p2].each do |p|
|
||||
|
Reference in New Issue
Block a user