Skip to content

Instantly share code, notes, and snippets.

@mjohnson9
Last active March 8, 2021 01:36
Show Gist options
  • Save mjohnson9/083ddc5df972359676853b4ea13e4e1c to your computer and use it in GitHub Desktop.
Save mjohnson9/083ddc5df972359676853b4ea13e4e1c to your computer and use it in GitHub Desktop.
import Shortcuts 1092.8.7
#Color: Red, #Icon: shortcuts
// TODO: Add a check to see if at work and only use reminders from work if that's the case
filterReminders(input: All Reminders, filterType: All, filter: {Is Not Completed}, sortBy: End Date, order: Latest First) ->[Base Reminder List]
// Check for reminders due before now
filterReminders(input: Base Reminder List, filter: {Due Date: .before: Current Date}) ->[Past Reminder List]
// First, check for high priority reminders
filterReminders(input: Past Reminder List, filterType: All, filter: {Priority: Is: High}, sortBy: End Date, order: Latest First, limit: 1) ->[High Priority Reminder]
var Next Reminder = High Priority Reminder
// If the last check failed to find anything, check for medium priority reminders
if(Next Reminder == nil) {
filterReminders(input: Past Reminder List, filterType: All, filter: {Priority: Is: Medium}, sortBy: End Date, order: Latest First, limit: 1) ->[Medium Priority Reminder]
var Next Reminder = Medium Priority Reminder
}
// If the last check failed to find anything, check for low priority reminders
if(Next Reminder == nil) {
filterReminders(input: Past Reminder List, filterType: All, filter: {Priority: Is: Low}, sortBy: End Date, order: Latest First, limit: 1) ->[Low Priority Reminder]
var Next Reminder = Low Priority Reminder
}
// Finally, get reminders without a priority so that we can notify the user about them.
filterReminders(input: Past Reminder List, filterType: All, filter: {Priority: Is Not Set}, sortBy: End Date, order: Latest First) ->[Priority Unset Reminder]
// If the Next Reminder is still nil, use the latest Priority Unset Reminder
if(Next Reminder == nil) {
// We don't bother with a filter here because we just need it to return a single item sorted correctly
filterReminders(input: Priority Unset Reminder, sortBy: End Date, order: Latest First, limit: 1) ->[Filtered Priority Unset Reminder]
var Next Reminder = Filtered Priority Unset Reminder
}
// If there were no Priority Unset Reminders, use a reminder coming up within the next 3 days
if(Next Reminder == nil) {
filterReminders(input: Base Reminder List, filterType: All, filter: {Due Date: .next: 3 days}, sortBy: End Date, order: Oldest First, limit: 1) ->[Upcoming Reminder]
var Next Reminder = Upcoming Reminder
}
if(Next Reminder == nil) {
showResult(text: "There is nothing due in the past or the next 72 hours on your to-do list.")
exit()
}
showResult(text: "Work in progress")
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment