This commit is contained in:
@@ -60,7 +60,12 @@ async def create_shout(_, info, inp):
|
|||||||
'published_at': None,
|
'published_at': None,
|
||||||
'created_at': current_time, # Set created_at as Unix timestamp
|
'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)
|
new_shout = Shout(**shout_dict)
|
||||||
session.add(new_shout)
|
session.add(new_shout)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|||||||
Reference in New Issue
Block a user