Jellycuts / Jellycuts-Issues

A public issue tracker for the Jellycuts iOS app.
23 stars 0 forks source link

Filter Issues #33

Closed ActuallyTaylor closed 3 years ago

ActuallyTaylor commented 3 years ago

Originally from nightexcessive #1984

Describe the bug

It seems that any time I try to use a filter, Shortcuts crashes as the Jellycuts Helper tries to create a link. I've had two other scripts cause it, but I've since deleted them. Here's the one that's doing it right now: https://gist.github.com/mjohnson9/083ddc5df972359676853b4ea13e4e1c Gist

Issue

The issue is with filters not converting correctly.

ActuallyTaylor commented 3 years ago

Shortcuts seemed to change the way filters are constructed. So I updated the structure.

mjohnson9 commented 3 years ago

Embedding the code in case the link goes dead and licensing under the 0-clause BSD so that it can be used however.

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")

License:

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.

mjohnson9 commented 3 years ago

The filter doesn’t seem to have been created correctly in the resulting shortcut. The code below results in the following screenshot. Note the difference between the filter defined in the code and the filter in the screenshot.

filterReminders(input: All Reminders, filterType: All, filter: {Is Not Completed}, sortBy: Last Modified Date, order: Latest First) ->[Base Reminder List Sort 1] // Sort by last modified date first

32FC5ED1-DD38-4EE2-8029-136A2B564518

ActuallyTaylor commented 3 years ago

Intersting. I will check this out again and see what if I can fix it. I am going to reopen the issue.

ActuallyTaylor commented 3 years ago

Okay I fixed this specific issue. I’m gonna continue working on the filters to see if there are any other issues.

mjohnson9 commented 3 years ago

I don’t know if 0.9 (20) was supposed to contain the fix for https://github.com/ActuallyZach/Jellycuts-Issues/issues/33#issuecomment-792416845, but I’m still experiencing it with 0.9 (20).

ActuallyTaylor commented 3 years ago

0.9(20) does not include the fix for #33 (comment). It will be in 0.9(21)