Inspect action and return end result
(job, peaks)
| 91 | |
| 92 | |
| 93 | def inspector(job, peaks): |
| 94 | """Inspect action and return end result""" |
| 95 | lc_extra_check_h, lc_extra_check_d = False, False |
| 96 | |
| 97 | hourly_peak = peaks[job]["hourly"] |
| 98 | daily_peak = peaks[job]["daily"] |
| 99 | |
| 100 | # if like record exceeds its peak value, no comment will not also be sent |
| 101 | if job == "comments": |
| 102 | hourly_like_peak = peaks["likes"]["hourly"] |
| 103 | daily_like_peak = peaks["likes"]["daily"] |
| 104 | |
| 105 | # interesting catch: use `>` instead of '>=' here :D |
| 106 | if hourly_like_peak is not None: |
| 107 | hourly_like_record = get_record("likes", "hourly") |
| 108 | lc_extra_check_h = hourly_like_record > hourly_like_peak |
| 109 | |
| 110 | if daily_like_peak is not None: |
| 111 | daily_like_record = get_record("likes", "daily") |
| 112 | lc_extra_check_d = daily_like_record > daily_like_peak |
| 113 | |
| 114 | # inspect |
| 115 | if hourly_peak is not None: |
| 116 | hourly_record = get_record(job, "hourly") |
| 117 | |
| 118 | if hourly_record >= hourly_peak: |
| 119 | return True, "hourly", "job" |
| 120 | |
| 121 | if daily_peak is not None: |
| 122 | daily_record = get_record(job, "daily") |
| 123 | |
| 124 | if daily_record >= daily_peak: |
| 125 | return True, "daily", "job" |
| 126 | |
| 127 | # extra like & comment inspection |
| 128 | if lc_extra_check_h: |
| 129 | return True, "hourly", "lc_extra" |
| 130 | |
| 131 | elif lc_extra_check_d: |
| 132 | return True, "daily", "lc_extra" |
| 133 | |
| 134 | # inspection completed without a quotient breach |
| 135 | return False, None, None |
| 136 | |
| 137 | |
| 138 | def stochasticity(peaks): |
no test coverage detected