Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Unreleased
Release Notes - 2020-11-02
--------------------------
- [#213] リリースノートの最新バージョンの記述を返すversionコマンドを追加

- [#214] URLを含む語録が削除できないバグ修正

Release Notes - 2020-10-30
--------------------------
Expand Down
36 changes: 36 additions & 0 deletions src/alembic/migrations/versions/aa8a8e0293ac_replace_nbsp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""replace &nbsp

Revision ID: aa8a8e0293ac
Revises: 98ecbc1e5b66
Create Date: 2020-11-02 12:48:17.045798

"""
import os

import sqlalchemy as sa
from sqlalchemy.orm import sessionmaker

from alembic import op
from haro.plugins.create_models import Term

# revision identifiers, used by Alembic.
revision = 'aa8a8e0293ac'
down_revision = '98ecbc1e5b66'
branch_labels = None
depends_on = None

engine = sa.create_engine(os.environ.get("SQLALCHEMY_URL"))
Session = sessionmaker(bind=engine)

def upgrade():
# ハイパーリンクがTerm.wordに含まれている場合、半角スペースが\xa0になってしまっているケースが存在するため置き換える
s = Session()
terms = s.query(Term).filter(Term.word.like('%\xa0%'))
print(terms)
for term in terms:
term.word = term.word.replace('\xa0', ' ')
s.commit()


def downgrade():
pass
4 changes: 4 additions & 0 deletions src/haro/plugins/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ def del_term(message, command, word):
:param str command: 登録済のコマンド名
:param str word: 削除する語録
"""
# ハイパーリンクをコピペした際前後のスペースが\xa0になっているケースがあるため変換
word = word.replace('\xa0', ' ')
s = Session()
term = (s.query(Term)
.filter(Term.create_command == command.id)
Expand All @@ -330,6 +332,8 @@ def add_term(message, command, word):
:param str command: 登録済のコマンド名
:param str word: 登録する語録
"""
# ハイパーリンクをコピペした際前後のスペースが\xa0になっているケースがあるため変換
word = word.replace('\xa0', ' ')
s = Session()
term = (s.query(Term)
.select_from(join(Term, CreateCommand))
Expand Down