forestav commited on
Commit
3d71aa9
·
1 Parent(s): 388f86f

set workflow instead of manual loop

Browse files
Files changed (3) hide show
  1. .github/workflows/actions.yml +32 -0
  2. main.py +7 -6
  3. settings.py +2 -2
.github/workflows/actions.yml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Run main.py on schedule
2
+
3
+ on:
4
+ schedule:
5
+ # Run the workflow every three hours
6
+ - cron: "0 */3 * * *"
7
+ workflow_dispatch: # Allows manual triggering of the workflow
8
+
9
+ jobs:
10
+ run-python-script:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ # Step 1: Check out the code
15
+ - name: Check out repository
16
+ uses: actions/checkout@v3
17
+
18
+ # Step 2: Set up Python
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v4
21
+ with:
22
+ python-version: "3.9" # Match your Python version
23
+
24
+ # Step 3: Install dependencies
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
29
+
30
+ # Step 4: Run the script
31
+ - name: Run main.py
32
+ run: python main.py
main.py CHANGED
@@ -26,14 +26,15 @@ def keep_updated():
26
  log.info(f"No ads found after timestamp '{last_timestamp}'")
27
 
28
  write_timestamp(new_timestamp)
29
- counter += 1
30
- log.info(f"Completed update {counter} of {MAX_UPDATES}")
 
31
 
32
- if counter == MAX_UPDATES:
33
- break
34
 
35
- log.info(f"Waiting {SLEEP_TIME_MINUTES} minutes before collecting ads again")
36
- sleep(SLEEP_TIME_MINUTES * 60)
37
 
38
  log.info('Finished')
39
 
 
26
  log.info(f"No ads found after timestamp '{last_timestamp}'")
27
 
28
  write_timestamp(new_timestamp)
29
+ break
30
+ #counter += 1
31
+ #log.info(f"Completed update {counter} of {MAX_UPDATES}")
32
 
33
+ #if counter == MAX_UPDATES:
34
+ # break
35
 
36
+ #log.info(f"Waiting {SLEEP_TIME_MINUTES} minutes before collecting ads again")
37
+ #sleep(SLEEP_TIME_MINUTES * 60)
38
 
39
  log.info('Finished')
40
 
settings.py CHANGED
@@ -11,8 +11,8 @@ BASE_URL = 'https://jobstream.api.jobtechdev.se'
11
  STREAM_URL = f"{BASE_URL}/stream"
12
  SNAPSHOT_URL = f"{BASE_URL}/snapshot"
13
 
14
- SLEEP_TIME_MINUTES = 0.1
15
- MAX_UPDATES = 4
16
 
17
  DATE_FORMAT = "%Y-%m-%dT%H:%M:%S"
18
 
 
11
  STREAM_URL = f"{BASE_URL}/stream"
12
  SNAPSHOT_URL = f"{BASE_URL}/snapshot"
13
 
14
+ SLEEP_TIME_MINUTES = 5
15
+ MAX_UPDATES = 50
16
 
17
  DATE_FORMAT = "%Y-%m-%dT%H:%M:%S"
18