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

Add multi chats support #13

Merged
merged 2 commits into from
Sep 17, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Drop useless indexes
  • Loading branch information
TheBlackArroVV committed Sep 17, 2019
commit 38baeeaa188fa8fcb2bdabb33de0732e27a5d5d1
2 changes: 1 addition & 1 deletion app/services/karma_service.rb
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ def statistic_message

def username(username)
name = username || 'null'
until name.length == 20 do name += ' ' end
until name.length >= 20 do name += ' ' end
name
end

6 changes: 3 additions & 3 deletions db/database.rb
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ def increase_karma(user_data, chat_id)
if user.first
update_user_karma_counter(user, user.first[:count] + 1)
else
create_user(user_data, 1)
create_user(user_data, 1, chat_id)
end
end

@@ -23,7 +23,7 @@ def decrease_karma(user_data, chat_id)
if user.first
update_user_karma_counter(user, user.first[:count] - 1)
else
create_user(user_data, chat_id)
create_user(user_data, 0, chat_id)
end
end

@@ -42,7 +42,7 @@ def count_grouped_users(chat_id)
private

def create_user(user_data, karma_count = 0, chat_id)
users.insert(UserBuilder.call(user_data, karma_count))
users.insert(UserBuilder.call(user_data, karma_count, chat_id))
end

def update_user_karma_counter(user, new_count)
8 changes: 0 additions & 8 deletions db/migrations/5_change_index_on_users.rb

This file was deleted.

File renamed without changes.
7 changes: 7 additions & 0 deletions db/migrations/7_drop_index_on_username.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Sequel.migration do
change do
drop_index :users, :user_name
drop_index :users, :telegram_id
add_index :users, :telegram_id
end
end