This commit is contained in:
parent
8d06f59702
commit
187c14d6b0
|
@ -60,7 +60,12 @@ async def create_shout(_, info, inp):
|
|||
'published_at': None,
|
||||
'created_at': current_time, # Set created_at as Unix timestamp
|
||||
}
|
||||
|
||||
same_slug_shout = session.query(Shout).filter(Shout.slug == shout_dict.get('slug')).first()
|
||||
c = 1
|
||||
while same_slug_shout is not None:
|
||||
same_slug_shout = session.query(Shout).filter(Shout.slug == shout_dict.get('slug')).first()
|
||||
c += 1
|
||||
shout_dict['slug'] += f'-{c}'
|
||||
new_shout = Shout(**shout_dict)
|
||||
session.add(new_shout)
|
||||
session.commit()
|
||||
|
|
Loading…
Reference in New Issue
Block a user