Skip to content

Commit ba19e40

Browse files
authored
added checks for tracker (#23)
1 parent e7e677c commit ba19e40

File tree

4 files changed

+95
-61
lines changed

4 files changed

+95
-61
lines changed

bot/google_sheet.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ def get_trackers(sheet_id):
157157
.execute()
158158
)
159159
values = result.get("values", [])
160-
return values[0]
160+
if values:
161+
return values[0]
162+
else:
163+
return
161164

162165

163166
def update_rows(sheet_id, day, new_row, first_row):

bot/telegram_bot.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,35 @@ def set_up(update, context) -> int:
9797
current_datetime = dt.datetime.now(timezone)
9898
day = current_datetime.day
9999
month = current_datetime.strftime("%b")
100-
gs.update_rows(sheet_id, day, 4, 5) # New users start from row 5
101-
gs.create_date(sheet_id, day, month, 5)
100+
101+
# get tracker data to check if got input
102+
trackers = gs.get_trackers(sheet_id)
103+
if trackers: # If got input
104+
day_tracker = int(trackers[0])
105+
first_row = int(trackers[3])
106+
if day_tracker == day:
107+
pass
108+
elif day_tracker < day:
109+
prev_month = (current_datetime - dt.timedelta(days=1)).strftime(
110+
"%b"
111+
)
112+
gs.update_prev_day(sheet_id, prev_month, first_row)
113+
new_row = gs.get_new_row(sheet_id, month)
114+
first_row = new_row + 1
115+
gs.update_rows(sheet_id, day, new_row, first_row)
116+
gs.create_date(sheet_id, day, month, first_row)
117+
elif day == 1:
118+
new_row = 4
119+
first_row = 5
120+
gs.update_rows(sheet_id, day, new_row, first_row)
121+
gs.create_date(sheet_id, day, month, first_row)
122+
else: # New sheet
123+
new_row = 4
124+
first_row = 5
125+
gs.update_rows(
126+
sheet_id, day, new_row, first_row
127+
) # New users start from row 5
128+
gs.create_date(sheet_id, day, month, first_row)
102129
update.message.reply_text(SUCCESS_LINK_TEXT)
103130
return ConversationHandler.END
104131
except Exception as e:

release_notes.md

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,34 @@
11
# Release Notes
22

3-
## Version 1.0.0 - Date: 20 May 2023
4-
- Initial Launch
5-
6-
## Version 1.1.0 - Date: 21 May 2023
7-
### New Features 🆕
8-
- Back button
9-
- Added help command
10-
11-
### Bug Fixes 🛠️
12-
- Remove 'Transport' category from others
13-
- Fixed others and transport row tracker
14-
- Fixed first row tracker
15-
16-
### Enhancement 🔥
17-
- Refactor file structure
18-
19-
## Version 1.2.0 - Date: 24 May 2023
20-
### New Features 🆕 (Planned deployment: 27 May 2023)
21-
- Retrieve past transaction with /retrievetransaction command
22-
- Add income with /addincome command
23-
24-
### Enhancement 🔥
25-
- Increase number of options for add others
26-
27-
## Version 2.0.0 - Date 28 May 2023
28-
### Enhancement 🔥
29-
- Cloud hosting w Flask & Vercel 🎉
30-
- Move string to text_str.py
3+
## Version 2.1.5 - Date 30 July 2023
4+
### Bug Fix 🛠️
5+
- Added tracker check when adding google sheet to prevent resetting of (existing) tracker
316

7+
## Version 2.1.4 - Date 16 July 2023
328
### Bug Fix 🛠️
33-
- Allow negative price entry
9+
- Added end conversation handler for get day transaction
3410

35-
### To note ❗
36-
- Remove sql functions
37-
- python-telegram-bot library changed to 13.7
38-
- Move services account to environment variable
39-
- Please read the new README for developer
11+
## Version 2.1.3 - Date 16 July 2023
12+
### Enhancement 🔥
13+
- Allows user to add multiple settings for quick transport
14+
- If there is only one settings, that will be used as default (/addtransport only)
15+
- Revamp Google Sheet with new looks
4016

41-
## Version 2.0.1 - Date 1 Jun 2023
4217
### Bug Fix 🛠️
43-
- Fix month abbreviation
44-
- Fix updating of previous month
18+
- Skip empty cells for payment & category
4519

4620
### For Developer 🧑‍💻
47-
- Added a new updates.py file to push updates to all users
48-
- To run updates, call functions in push_updates.py
21+
- Remove firebase codes
4922

50-
## Version 2.0.2 - Date 1 Jun 2023
23+
## Version 2.1.2 - Date 26 Jun 2023
5124
### Bug Fix 🛠️
52-
- Day 1 sum creation bug
25+
- When new users join, new date entry was not created
26+
- Quick add settings not sending proper error message when either transport or others has been configured
27+
28+
## Version 2.1.1 - Date 8 Jun 2023
29+
### Enhancement 🔥
30+
- Migrate to use firestore
31+
- Reformatted get overall transaction
5332

5433
## Version 2.1.0 - Date 1 Jun 2023
5534
### New Features 🆕
@@ -61,31 +40,53 @@
6140
### For Developer 🧑‍💻
6241
- When you run test.py, ngrok will auto setup with the correct webhook!
6342

43+
## Version 2.0.2 - Date 1 Jun 2023
44+
### Bug Fix 🛠️
45+
- Day 1 sum creation bug
6446

65-
## Version 2.1.1 - Date 8 Jun 2023
47+
## Version 2.0.1 - Date 1 Jun 2023
48+
### Bug Fix 🛠️
49+
- Fix month abbreviation
50+
- Fix updating of previous month
51+
52+
### For Developer 🧑‍💻
53+
- Added a new updates.py file to push updates to all users
54+
- To run updates, call functions in push_updates.py
55+
56+
## Version 2.0.0 - Date 28 May 2023
6657
### Enhancement 🔥
67-
- Migrate to use firestore
68-
- Reformatted get overall transaction
58+
- Cloud hosting w Flask & Vercel 🎉
59+
- Move string to text_str.py
6960

70-
## Version 2.1.2 - Date 26 Jun 2023
7161
### Bug Fix 🛠️
72-
- When new users join, new date entry was not created
73-
- Quick add settings not sending proper error message when either transport or others has been configured
62+
- Allow negative price entry
7463

64+
### To note ❗
65+
- Remove sql functions
66+
- python-telegram-bot library changed to 13.7
67+
- Move services account to environment variable
68+
- Please read the new README for developer
69+
70+
## Version 1.2.0 - Date: 24 May 2023
71+
### New Features 🆕 (Planned deployment: 27 May 2023)
72+
- Retrieve past transaction with /retrievetransaction command
73+
- Add income with /addincome command
7574

76-
## Version 2.1.3 - Date 16 July 2023
7775
### Enhancement 🔥
78-
- Allows user to add multiple settings for quick transport
79-
- If there is only one settings, that will be used as default (/addtransport only)
80-
- Revamp Google Sheet with new looks
76+
- Increase number of options for add others
8177

82-
### Bug Fix 🛠️
83-
- Skip empty cells for payment & category
78+
## Version 1.1.0 - Date: 21 May 2023
79+
### New Features 🆕
80+
- Back button
81+
- Added help command
8482

85-
### For Developer 🧑‍💻
86-
- Remove firebase codes
83+
### Bug Fixes 🛠️
84+
- Remove 'Transport' category from others
85+
- Fixed others and transport row tracker
86+
- Fixed first row tracker
8787

88+
### Enhancement 🔥
89+
- Refactor file structure
8890

89-
## Version 2.1.4 - Date 16 July 2023
90-
### Bug Fix 🛠️
91-
- Added end conversation handler for get day transaction
91+
## Version 1.0.0 - Date: 20 May 2023
92+
- Initial Launch

test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ def index():
2828
if __name__ == "__main__":
2929
public_url = ngrok.connect(5000, "http").public_url
3030
updater.bot.set_webhook(url=f"{public_url}/webhook")
31+
print("#" * 50)
32+
print(f"# Bot is running at @{updater.bot.get_me().username} #")
33+
print("#" * 50)
3134
app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))

0 commit comments

Comments
 (0)