fix ping_cost not getting summed with previous value

pull/195/head
Aevann 2023-08-13 19:02:55 +03:00
parent d2d13eeeee
commit 4623e7c1a3
5 changed files with 9 additions and 5 deletions

View File

@ -139,7 +139,7 @@ class Comment(Base):
ban_reason = Column(String)
treasure_amount = Column(String)
slots_result = Column(String)
ping_cost = Column(Integer)
ping_cost = Column(Integer, default=0)
blackjack_result = Column(String)
casino_game_id = Column(Integer, ForeignKey("casino_games.id"))
chudded = Column(Boolean, default=False)

View File

@ -60,7 +60,7 @@ class Post(Base):
new = Column(Boolean)
notify = Column(Boolean)
chudded = Column(Boolean, default=False)
ping_cost = Column(Integer)
ping_cost = Column(Integer, default=0)
bump_utc = Column(Integer)
author = relationship("User", primaryjoin="Post.author_id==User.id")

View File

@ -210,7 +210,7 @@ def execute_snappy(post, v):
)
if ping_cost:
c.ping_cost = ping_cost
c.ping_cost += ping_cost
g.db.add(c)

View File

@ -159,7 +159,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None, followers_pi
v.charge_account('combined', cost)
if log_cost:
log_cost.ping_cost = cost
log_cost.ping_cost += cost
return 'everyone'
elif i.group(1) == 'jannies':
group = None
@ -186,7 +186,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None, followers_pi
abort(403, f"You need {cost} coins to mention these ping groups!")
if log_cost:
log_cost.ping_cost = cost
log_cost.ping_cost += cost
if i.group(1) in {'biofoids','neofoids','jannies'}:
coin_receivers.update(member_ids)

View File

@ -0,0 +1,4 @@
update posts set ping_cost=0 where ping_cost is null;
alter table posts alter column ping_cost set not null;
update comments set ping_cost=0 where ping_cost is null;
alter table comments alter column ping_cost set not null;