Enhance booking time management by adding configurable time slots and improve sync workflow error handling
This commit is contained in:
parent
ffbac14108
commit
0dd5432bb8
3 changed files with 32 additions and 20 deletions
15
.github/workflows/sync-to-public.yml
vendored
15
.github/workflows/sync-to-public.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -12,4 +12,20 @@ DEFAULT_HEADERS = {
|
|||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0',
|
||||
'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
19
main.py
|
|
@ -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'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue