Skip to content

Commit 5c33078

Browse files
authored
Revert "Add async tasks and mailer services"
1 parent b838141 commit 5c33078

23 files changed

+47
-565
lines changed

apps/startup/apps.py

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,14 @@
11
from django.apps import AppConfig
2+
from ..ticketscraping.scraping import start
23
from datetime import datetime
34
from threading import Thread
4-
from multiprocessing import Process
5-
6-
7-
def run_prepare():
8-
# import module inside the child process to prevent execution in the parent process
9-
print(
10-
f"ticket scraping service started at {datetime.now().strftime('%d/%m/%Y %H:%M:%S')}")
11-
12-
# start sender socket
13-
from apps.ticketscraping.schedulers.async_tasks_scheduler import async_tasks_scheduler
14-
conn_thread = Thread(target=async_tasks_scheduler.connect)
15-
conn_thread.start()
16-
# wait for async tasks handler to connect
17-
conn_thread.join()
18-
19-
# start itself (scraping)
20-
from apps.ticketscraping.scraping import start
21-
start()
22-
23-
24-
def run():
25-
# starter
26-
p = Process(target=run_prepare, daemon=True)
27-
p.start()
28-
# start receiver socket
29-
from apps.ticketscraping.connection.asyn_tasks_receiver import run
30-
conn_process = Process(target=run)
31-
conn_process.start()
32-
conn_process.join()
335

346

357
class MyAppConfig(AppConfig):
368
name = "apps.startup"
379
verbose_name = "start tmtracker"
3810

3911
def ready(self):
40-
run()
12+
print(
13+
f"server started at {datetime.now().strftime('%d/%m/%Y %H:%M:%S')}")
14+
Thread(target=start).start()

apps/storage/base.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,12 @@ def find_one_and_update__(coll: collection.Collection, filter: dict, update=dict
3030
def find_one_and_delete__(coll: collection.Collection, filter: dict):
3131
return coll.find_one_and_delete(filter)
3232

33-
def find_one__(coll: collection.Collection, filter: dict, projection, **kwargs):
34-
return coll.find_one(filter=filter, projection=projection, **kwargs)
33+
def find_one__(coll: collection.Collection, filter: dict, projection):
34+
return coll.find_one(filter=filter, projection=projection)
3535

3636
def find_many__(coll: collection.Collection, filter: dict, projection, **kwargs):
3737
return coll.find(filter=filter, projection=projection, **kwargs)
3838

39-
def count_docs__(coll: collection.Collection, filter: dict):
40-
return coll.count_documents(filter=filter)
41-
42-
def estimated_count_docs__(coll: collection.Collection):
43-
return coll.estimated_document_count()
44-
4539
def watch__(coll: collection.Collection, **kwargs):
4640
return coll.watch(**kwargs)
4741

apps/storage/query.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

apps/storage/storage.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,17 @@ def find_one_and_delete(collection_name, filter: dict, db_name="tickets"):
5151
return find_one_and_delete__(coll, filter)
5252

5353
# find one
54-
def find_one(collection_name, filter: dict, projection=None, db_name="tickets", **kwargs):
54+
def find_one(collection_name, filter: dict, projection=None, db_name="tickets"):
5555
db = get_db_handle(db_name)
5656
coll = db[collection_name]
57-
return find_one__(coll, filter, projection, **kwargs)
57+
return find_one__(coll, filter, projection)
5858

5959
# find many
6060
def find_many(collection_name, filter: dict, projection=None, db_name="tickets", **kwargs):
6161
db = get_db_handle(db_name)
6262
coll = db[collection_name]
6363
return list(find_many__(coll, filter, projection, **kwargs))
6464

65-
# count with filter
66-
def count_docs(collection_name, filter: dict, db_name="tickets"):
67-
db = get_db_handle(db_name)
68-
coll = db[collection_name]
69-
return count_docs__(coll, filter)
70-
71-
# count all docs in a collection
72-
def estimated_count_docs(collection_name, db_name="tickets"):
73-
db = get_db_handle(db_name)
74-
coll = db[collection_name]
75-
return estimated_count_docs__(coll)
76-
7765
# watch changes
7866
def watch(collection_name, db_name="tickets", **kwargs):
7967
db = get_db_handle(db_name)

apps/ticketscraping/connection/asyn_tasks_receiver.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

apps/ticketscraping/connection/mail_receiver.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

apps/ticketscraping/connection/receiver.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

apps/ticketscraping/connection/receiver_process.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

apps/ticketscraping/connection/sender.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

apps/ticketscraping/constants.py

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
from uuid import uuid4
22

3-
# services - async action handlers
4-
ASYNC_TASKS_RECEIVER_PORT = 8100
5-
MAIL_RECEIVER_PORT = 8200
6-
SERVICE_LOCALHOST = 'localhost'
7-
83
ANTIBOT_JS_CODE_URL = "https://epsf.ticketmaster.com/eps-d"
94
TOKEN_INTERROGATION_URL = "https://epsf.ticketmaster.com/eps-d?d=www.ticketmaster.com"
105

@@ -22,39 +17,16 @@ def get_top_picks_url(
2217
"BEST_AVAILABLE_SEATS": "best-available-seats",
2318
"BEST_HISTORY_SEATS": "best-history-seats"
2419
}
25-
26-
SUBSCRIBE_REQUEST_PROPS = {
27-
'NAME': 'name',
28-
'TARGET_PRICE': 'target_price',
29-
'TOLERANCE': 'tolerance',
30-
'TICKET_NUM': 'ticket_num',
31-
'TM_EVENT_ID': 'tm_event_id'
32-
}
33-
34-
def filter_obj_from_attrs(obj, atts: dict[str,str]):
35-
res = {}
36-
for key in atts.values():
37-
if key in obj:
38-
res[key] = obj[key]
39-
return res
40-
41-
42-
# metric thresholds
43-
MINIMUM_HISTORY_DATA = 3
44-
PERCENT_OF_CHANGE = 0.5
45-
PERCENTILE_HISTORY_PRICES = 0.25
46-
ALERT_SEATS_MAX_COUNT = 3
47-
4820
def get_top_picks_header(): return {
4921
**BASIC_REQ_HEADER,
5022
"tmps-correlation-id": str(uuid4())
5123
}
5224

53-
def get_top_picks_query_params(qty: int, target_price: int, tolerance: int): return {
25+
def get_top_picks_query_params(qty, priceInterval): return {
5426
'show': 'places maxQuantity sections',
5527
'mode': 'primary:ppsectionrow resale:ga_areas platinum:all',
5628
'qty': qty,
57-
'q': f"and(not(\'accessible\'),any(listprices,$and(gte(@,{target_price - tolerance}),lte(@,{target_price + tolerance}))))",
29+
'q': f"and(not(\'accessible\'),any(listprices,$and(gte(@,{priceInterval[0]}),lte(@,{priceInterval[1]}))))",
5830
'includeStandard': 'true',
5931
'includeResale': 'true',
6032
'includePlatinumInventoryType': 'false',

0 commit comments

Comments
 (0)