Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Merge branch 'dev' into cypress-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TumiPare committed Sep 28, 2023
2 parents 5bde639 + 4148da2 commit be7502e
Show file tree
Hide file tree
Showing 6 changed files with 293 additions and 287 deletions.
16 changes: 9 additions & 7 deletions api/scripts/fetchstatstest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
testing_endpoint = "https://witpa.codelog.co.za/api/fetchSuburbStats"
schedule_endpoint = "https://witpa.codelog.co.za/api/fetchScheduleData"
schedule_endpoint = "http://127.0.0.1:8000/api/fetchScheduleData"
maponoff_endpoint = "https://witpa.codelog.co.za/api/fetchTimeForPolygon"
maponoff_endpoint = "http://127.0.0.1:8000/api/fetchTimeForPolygon"
def sendRequest():
body = {
Expand All @@ -20,8 +21,8 @@ def sendRequest():

def sendScheduleRequest():
body = {
#"suburbId" :18231
"suburbId" : 18210
#"suburbId" :18231
"suburbId" : 18186
}
request = json.dumps(body)
headers = {
Expand All @@ -32,20 +33,21 @@ def sendScheduleRequest():

def sendTimeForPolygonRequest():
body = {
#"suburbId" :18057
#"suburbId" : 18231
"suburbId" : 18195
#"suburbId" :18057
#"suburbId" : 18231
"suburbId" : 18196
}
print(body)
request = json.dumps(body)
headers = {
"Content-Type":"application/json"
}
response = requests.post(url=maponoff_endpoint,data=request,headers=headers)
print(response.text)
if (__name__ == "__main__"):
sendRequest()
#sendRequest()
print("=================================================================================")
sendScheduleRequest()
print("=================================================================================")
sendTimeForPolygonRequest()
#sendTimeForPolygonRequest()

8 changes: 6 additions & 2 deletions api/src/loadshedding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,11 @@ impl TimeScheduleEntity {
.with_hour(if start {
self.start_hour as u32
} else {
self.stop_hour as u32
if self.stop_hour != 24 {
self.stop_hour as u32
} else {
0
}
})
.unwrap()
.with_minute(if start {
Expand All @@ -708,7 +712,7 @@ impl TimeScheduleEntity {
self.stop_minute as u32
})
.unwrap();
if time < time_to_search {
if time < time_to_search && !start {
time = time.checked_add_signed(chrono::Duration::days(1)).unwrap();
}
time
Expand Down
4 changes: 2 additions & 2 deletions api/src/scraper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ pub fn convert_to_ints(time_range:&str) -> Result<Times,Json<ApiError<'static>>>
return Err(Json(ApiError::ScraperUploadError(
"You have a malformed starting hour, please fix this, HH <= 23",
)));
} else if potential_times.end_hour >= 24 {
} else if potential_times.end_hour > 24 || potential_times.end_hour == 0 {
return Err(Json(ApiError::ScraperUploadError(
"You have a malformed end hour, please fix this, HH <= 23",
"You have a malformed end hour, please fix this, 0 < HH <= 24",
)));
} else if potential_times.start_minute >= 60 {
return Err(Json(ApiError::ScraperUploadError(
Expand Down
Loading

0 comments on commit be7502e

Please sign in to comment.