diff --git a/bot/database_service/firestore_service.py b/bot/database_service/firestore_service.py index 4e96f9b..a3c776f 100644 --- a/bot/database_service/firestore_service.py +++ b/bot/database_service/firestore_service.py @@ -104,3 +104,12 @@ def get_all_user_id(self): return user_ids except Exception as e: raise DatabaseError(message="Error getting all user ids", extra_info=str(e)) + + # Get user count + def get_user_count(self): + try: + users_ref = self.db.collection(self.collection_name) + user_count = len([user.id for user in users_ref.stream()]) + return user_count + except Exception as e: + raise DatabaseError(message="Error getting user count", extra_info=str(e)) \ No newline at end of file diff --git a/bot/error_handler.py b/bot/error_handler.py index 4d308af..50356b5 100644 --- a/bot/error_handler.py +++ b/bot/error_handler.py @@ -10,6 +10,7 @@ def __init__(self, error_class, message="An error occurred", extra_info=""): self.message = message self.extra_info = extra_info self.error_class = error_class + logging.error(f"{error_class}: {message} {extra_info}") super().__init__(f"{self.error_class}: {self.message}") class GoogleSheetError(BaseError): diff --git a/bot/telegram_bot.py b/bot/telegram_bot.py index f36dfb9..b4a5cb1 100644 --- a/bot/telegram_bot.py +++ b/bot/telegram_bot.py @@ -1037,7 +1037,7 @@ def send_new_feature_message(context, new_feature_message): parse_mode=ParseMode.HTML, ) no_of_users += 1 - except Exception: + except Exception as e: try: chat = context.bot.get_chat(chat_id=user_id) username = chat.username if chat.username else "?" @@ -1062,10 +1062,10 @@ def notify_all(update, context): if not new_feature_message: update.message.reply_text("Please provide a message to send.") return - + no_of_users = db.get_user_count() keyboard = [ [ - InlineKeyboardButton("Confirm Send", callback_data="confirm_send"), + InlineKeyboardButton(f"Send to {no_of_users} users", callback_data="confirm_send"), InlineKeyboardButton("Cancel", callback_data="cancel_send"), ] ] diff --git a/release_notes.md b/release_notes.md index 0a43e35..0664769 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,4 +1,12 @@ # Release Notes +## Version 2.4.1.2 - Date 12 May 2024 +### Bug Fix 🛠️ +- Error handling for `/notifyall` command +- Add users count for `/notifyall` command + +### For Developer 🧑‍💻 +- Logging of error info message + ## Version 2.4.1 - Date 12 May 2024 ### Enhancement 🔥 - Added google form for reporting bugs, feedbacks and feature requests @@ -33,7 +41,7 @@ - Added test for database module ## Version 2.3.3 - Date 1 May 2024 -### Minor Fix 🛠️ +### Bug Fix 🛠️ - Add datetime and username for logging purposes - Add more message to help command