Enhance booking time management by adding configurable time slots and improve sync workflow error handling

This commit is contained in:
b267a 2026-01-30 18:28:49 +01:00
parent ffbac14108
commit 0dd5432bb8
3 changed files with 32 additions and 20 deletions

View file

@ -10,12 +10,23 @@ jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Check if token is set
run: |
if [ -z "${{ secrets.PUBLIC_REPO_TOKEN }}" ]; then
echo "❌ ERROR: PUBLIC_REPO_TOKEN secret is not set!"
exit 1
else
echo "✅ PUBLIC_REPO_TOKEN is set"
fi
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Remove sync workflow and push to public repo
env:
TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
run: |
# Configure git
git config user.name "github-actions[bot]"
@ -28,6 +39,6 @@ jobs:
git rm .github/workflows/sync-to-public.yml
git commit -m "Remove sync workflow for public repo"
# Push to public repo
git remote add public https://x-access-token:${{ secrets.PUBLIC_REPO_TOKEN }}@github.com/wiestju/anny-booking-automation.git
# Push to public repo using env var (more secure)
git remote add public "https://x-access-token:${TOKEN}@github.com/wiestju/anny-booking-automation.git"
git push public temp-sync-branch:main --force

View file

@ -13,3 +13,19 @@ DEFAULT_HEADERS = {
'accept': 'application/vnd.api+json',
'accept-encoding': 'plain'
}
# Booking time slots (in order of priority)
BOOKING_TIMES = [
{
'start': '14:00:00',
'end': '19:00:00'
},
{
'start': '09:00:00',
'end': '13:00:00'
},
{
'start': '20:00:00',
'end': '23:45:00'
},
]

19
main.py
View file

@ -7,7 +7,7 @@ from auth.session import AnnySession
from booking.client import BookingClient
from utils.helpers import get_future_datetime
import pytz
from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER
from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER, BOOKING_TIMES
def main():
load_dotenv('.env', override=True)
@ -40,22 +40,7 @@ def main():
elif seconds_until_midnight > max_wait_seconds:
print(f"⚡ More than 10 min until midnight, executing immediately...")
times = [
{
'start': '14:00:00',
'end': '19:00:00'
},
{
'start': '09:00:00',
'end': '13:00:00'
},
{
'start': '20:00:00',
'end': '24:00:00'
},
]
for time_ in times:
for time_ in BOOKING_TIMES:
try:
start = get_future_datetime(hour=time_['start'])
end = get_future_datetime(hour=time_['end'])