Skip to content

Commit f0d9256

Browse files
committed
use minutes instead of hours when creating reports
1 parent e8981b3 commit f0d9256

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

app/apple_fetch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def is_success(self) -> bool:
3535
return self.statusCode == "200"
3636

3737

38-
def apple_fetch(security_headers: dict, ids, hours_ago: int = 1) -> ResponseDto:
38+
def apple_fetch(security_headers: dict, ids,minutes_ago: int = 15) -> ResponseDto:
3939
logger.info("Fetching locations from Apple API for %s", ids)
40-
startdate = unix_epoch() - hours_ago * 60 * 60
40+
startdate = unix_epoch() - minutes_ago * 60 * 60 * 60
4141
enddate = unix_epoch()
4242

4343
response = _acsnservice_fetch(security_headers, ids, startdate, enddate)

app/device_service.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def fetch_and_report_locations_for_devices(
1616
security_headers: ICloudCredentials,
1717
page: int,
1818
limit: int,
19-
hours_ago: int,
19+
minutes_ago: int,
2020
trackers_filter: set[str] = None,
2121
send_reports: bool = True,
2222
):
@@ -29,7 +29,7 @@ def fetch_and_report_locations_for_devices(
2929
devices_to_consider = [device for device in device_response.data if device.name in trackers_filter]
3030
else:
3131
devices_to_consider = device_response.data
32-
apple_result = _fetch_location_metadata_from_icloud(devices_to_consider, hours_ago, security_headers)
32+
apple_result = _fetch_location_metadata_from_icloud(devices_to_consider, minutes_ago, security_headers)
3333
device_map = create_reports(locations=apple_result.results, devices=devices_to_consider)
3434

3535
devices_with_reports = list(device_map.values())
@@ -62,29 +62,29 @@ def fetch_limited_locations_and_generate_reports_for_them(
6262
limit: int,
6363
page: int,
6464
trackers_filter: set[str],
65-
hours_ago: int = 1,
65+
minutes_ago: int = 15,
6666
) -> list[BeamerDevice]:
6767
try:
6868
device_response = _get_device_metadata_from_space_invader_api(limit, page)
6969
except NoMoreLocationsToFetch:
7070
return []
7171

7272
devices_to_consider = [device for device in device_response.data if device.name in trackers_filter]
73-
apple_result = _fetch_location_metadata_from_icloud(devices_to_consider, hours_ago, security_headers)
73+
apple_result = _fetch_location_metadata_from_icloud(devices_to_consider, minutes_ago, security_headers)
7474
device_map = create_reports(locations=apple_result.results, devices=devices_to_consider)
7575

7676
return list(device_map.values())
7777

7878

7979
def _fetch_location_metadata_from_icloud(
8080
devices_to_consider: list[BeamerDevice],
81-
hours_ago: int,
81+
minutes_ago: int,
8282
security_headers: ICloudCredentials
8383
):
8484
apple_result = apple_fetch(
8585
security_headers.model_dump(mode='json', by_alias=True),
8686
[device.public_hash_base64 for device in devices_to_consider],
87-
hours_ago=hours_ago)
87+
minutes_ago=minutes_ago)
8888
if not apple_result.is_success:
8989
logger.error(f"Apple API Error[{apple_result.statusCode}]: {apple_result.error}")
9090
exit(1)

commands/location_and_reports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def resolve_locations(
2222
limit: int = 3000,
2323
page: int = 0,
2424
send_reports: bool = True,
25-
hours_ago: int = 1,
25+
minutes_ago: int = 15,
2626
print_report: bool = False,
2727
) -> None:
2828
security_headers = credentials_retriever.get_headers(api_key=settings.CREDENTIALS_API_KEY)
@@ -32,7 +32,7 @@ def resolve_locations(
3232
security_headers=ICloudCredentials(**security_headers),
3333
page=page,
3434
limit=limit,
35-
hours_ago=hours_ago,
35+
minutes_ago=minutes_ago,
3636
trackers_filter=tracker_ids,
3737
send_reports=send_reports,
3838
)

manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def fetch_locations(
4141
limit=limit,
4242
page=page,
4343
send_reports=send_reports,
44-
hours_ago=hours_ago,
44+
minutes=hours_ago * 60,
4545
print_report=True,
4646
)
4747

0 commit comments

Comments
 (0)