|
5 | 5 | MORNING_HOURS_END, |
6 | 6 | ) |
7 | 7 | from htk.tasks import BaseTask |
8 | | -from htk.utils.notifications import slack_notify |
| 8 | +from htk.utils.notifications import notify |
9 | 9 | from htk.utils.text.transformers import get_symbols |
10 | 10 |
|
11 | 11 |
|
|
15 | 15 | class GitHubReminderTask(BaseTask): |
16 | 16 | def __init__(self): |
17 | 17 | from htk.lib.github.cachekeys import GitHubReminderCooldown |
18 | | - super(GitHubReminderTask, self).__init__(cooldown_class=GitHubReminderCooldown) |
| 18 | + |
| 19 | + super(GitHubReminderTask, self).__init__( |
| 20 | + cooldown_class=GitHubReminderCooldown |
| 21 | + ) |
19 | 22 |
|
20 | 23 | def has_cooldown(self, user): |
21 | 24 | _has_cooldown = super(GitHubReminderTask, self).has_cooldown(user) |
22 | | - #_has_cooldown = False |
| 25 | + # _has_cooldown = False |
23 | 26 | return _has_cooldown |
24 | 27 |
|
25 | 28 | def get_users(self): |
26 | 29 | import htk.apps.accounts.filters as _filters |
27 | | - from htk.apps.accounts.utils.lookup import get_users_with_attribute_value |
28 | | - users = get_users_with_attribute_value('github_reminders', True, as_bool=True) |
29 | | - users = _filters.users_currently_at_local_time(users, BUSINESS_HOURS_START, MORNING_HOURS_END, isoweekdays=ISOWEEKDAY_WEEKDAYS) |
| 30 | + from htk.apps.accounts.utils.lookup import ( |
| 31 | + get_users_with_attribute_value, |
| 32 | + ) |
| 33 | + |
| 34 | + users = get_users_with_attribute_value( |
| 35 | + 'github_reminders', True, as_bool=True |
| 36 | + ) |
| 37 | + users = _filters.users_currently_at_local_time( |
| 38 | + users, |
| 39 | + BUSINESS_HOURS_START, |
| 40 | + MORNING_HOURS_END, |
| 41 | + isoweekdays=ISOWEEKDAY_WEEKDAYS, |
| 42 | + ) |
30 | 43 |
|
31 | 44 | return users |
32 | 45 |
|
33 | 46 | def execute(self, user): |
34 | | - slack_notify('Processing GitHub Reminders for {}'.format(user.username)) |
| 47 | + notify( |
| 48 | + 'Processing GitHub Reminders for {}'.format(user.username), |
| 49 | + use_messages=False, |
| 50 | + ) |
35 | 51 |
|
36 | 52 | now = user.profile.get_local_time() |
37 | 53 |
|
38 | 54 | valid_chars = 'A-Za-z0-9_\-/' |
39 | 55 | github_organizations = get_symbols( |
40 | 56 | user.profile.get_attribute('github_organizations') or '', |
41 | | - valid_chars=valid_chars |
| 57 | + valid_chars=valid_chars, |
42 | 58 | ) |
43 | 59 | github_repositories = get_symbols( |
44 | 60 | user.profile.get_attribute('github_repositories') or '', |
45 | | - valid_chars=valid_chars |
| 61 | + valid_chars=valid_chars, |
46 | 62 | ) |
47 | 63 |
|
48 | 64 | self.send_github_reminders( |
49 | 65 | user, |
50 | 66 | organizations=github_organizations, |
51 | | - repositories=github_repositories |
| 67 | + repositories=github_repositories, |
52 | 68 | ) |
53 | 69 |
|
54 | | - def send_github_reminders(self, user, organizations=None, repositories=None): |
| 70 | + def send_github_reminders( |
| 71 | + self, user, organizations=None, repositories=None |
| 72 | + ): |
55 | 73 | github_access_token = user.profile.get_attribute('github_access_token') |
56 | 74 | slack_webhook_url = user.profile.get_attribute('slack_webhook_url') |
57 | | - slack_channel = user.profile.get_attribute('github_reminders_slack_channel') |
58 | | - mention_here = user.profile.get_attribute('github_reminders_slack_mention_here') |
| 75 | + slack_channel = user.profile.get_attribute( |
| 76 | + 'github_reminders_slack_channel' |
| 77 | + ) |
| 78 | + mention_here = user.profile.get_attribute( |
| 79 | + 'github_reminders_slack_mention_here' |
| 80 | + ) |
59 | 81 |
|
60 | 82 | from htk.lib.github.bots import GitHubReminderSlackBot |
| 83 | + |
61 | 84 | bot = GitHubReminderSlackBot( |
62 | 85 | slack_webhook_url, |
63 | 86 | slack_channel, |
64 | 87 | github_access_token, |
65 | 88 | organizations=organizations, |
66 | 89 | repositories=repositories, |
67 | | - mention_here=mention_here |
| 90 | + mention_here=mention_here, |
68 | 91 | ) |
69 | 92 | bot.remind_pull_requests() |
0 commit comments