-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrackerHandler.py
More file actions
52 lines (43 loc) · 1.41 KB
/
trackerHandler.py
File metadata and controls
52 lines (43 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import db
from tracker import Tracker
# # List of active tracking links (see Tracker class)
# activeTrackers = []
# https://xkcd.com/1987/
def generateTracker(user, description):
"""
Generates a Tracker object and inserts it into the db
:param user: Username of user generating the Tracker
:param description: Description of the tracker link
:return: the new Tracker object
"""
tracker = Tracker(description)
db.insertTracker(tracker, user)
# activeTrackers.append(tracker)
return tracker
def getTrackerById(id):
"""
Gets a Tracker object by UUID
:param id: the UUID of the Tracker to search for
:return: the Tracker object or None
"""
# I'm doing this to keep consistency: all calls messing with trackers should be in this file
return db.selectTrackerById(id)
# TODO Handle expiring links and deletion of links?
# millis = utils.current_millis()
#
# # Testing
# print(db.selectTrackerById(id))
#
# for t in activeTrackers:
# # Automatically remove expired trackers
# if millis > t.expiration:
# logging.info(f"Removing expired tracker with UUID: {t.tId}")
# activeTrackers.remove(t)
# continue
#
# # Return current tracker if the Id is correct
# if t.tId == id:
# return t
#
# # Failed to find a tracker with the given Id
# return None