Skip to content

Commit b0b82cd

Browse files
committed
fix(mostql.py): add validation for project sign date to skip outdated projects
1 parent 054e6e7 commit b0b82cd

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

scripts/freelance/mostql.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import re
12
import os
23
import asyncio
34
import requests
5+
from datetime import datetime
46
from bs4 import BeautifulSoup
57
from shared.database_service import get_collection, save_to_database, check_database
68
from shared.telegram_service import send_text_message
@@ -122,16 +124,30 @@ def get_highlight(rate_str):
122124
# User Details:
123125
tableMeta = projectSoup.find("table", class_="table-meta")
124126
tableTrs = tableMeta.find_all("tr")
125-
signDate = tableTrs[0].find_all("td")[1].get_text(strip=True)
126-
employmentRate = tableTrs[1].find_all("td")[1].get_text(strip=True)
127127

128+
# Employment rate condition
129+
employmentRate = tableTrs[1].find_all("td")[1].get_text(strip=True)
128130
if not employmentRate == "لم يحسب بعد":
129131

130132
employmentRateValue = float(employmentRate.strip("%"))
131133

132134
if employmentRateValue < 50:
133135
print(
134-
f"Employment rate value less than 50% - skipping this project"
136+
f"\n❗ Employment rate value less than 50% - skipping this project\n"
137+
)
138+
continue
139+
140+
# Sign date condition
141+
signDate = tableTrs[0].find_all("td")[1].get_text(strip=True)
142+
match = re.search(r"\d{4}", signDate)
143+
if match:
144+
year_str = match.group()
145+
year = int(year_str)
146+
current_year = datetime.now().year
147+
148+
if year < current_year:
149+
print(
150+
"\n❗ Employment equal not calculated yet but sign date is old - skipping this project\n"
135151
)
136152
continue
137153

0 commit comments

Comments
 (0)