Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

active filters #26

Merged
merged 4 commits into from
Mar 5, 2018
Merged

active filters #26

merged 4 commits into from
Mar 5, 2018

Conversation

AnotherKamila
Copy link
Owner

@AnotherKamila AnotherKamila commented Mar 1, 2018

[creating a PR so I can comment on stuff]


This change is Reviewable

server.js Outdated


const export_filtered_tasks = (filter, callbacks) => {
// If a filter is already passed, don't bother checking taskwarrior's
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the use case I had for the filter in the query, this is not correct -- both the TW filters and the given filter should be applied. However, since the UI is not using the filter query parameter, maybe it would be simpler to drop it for now. Currently it's an unused feature polluting the code, so I'd argue it's better to just get rid of it.

server.js Outdated
cmd.push(filter)
cmd.push(ALWAYS_FILTER)
cmd.push('export')
const tw = spawn_tw(cmd)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my previous code was more readable than spreading this over multiple lines. Well, not really, but let cmd = ['rc.json.array=on', ALWAYS_FILTER, filter || '', 'export'] would be :D But maybe that's just me, feel free to ignore.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember I mentioned having an empty string as argument broke everything in a weird way :-p so that doesn't really work.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh :D okay, sorry :D

server.js Outdated
tw_filter.on('line', (line) => {
if (!filter && line) filter = line
})
tw_filter.on('close', (line) => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto -- close listener does not get a line.

server.js Outdated
tw_context.on('line', (line) => {
if (!context && line) context = line
})
tw_context.on('close', (line) => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://nodejs.org/api/readline.html#readline_event_close the close callback does not receive a line argument: "The listener function is called without passing any arguments."

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops :-D, I am pretty sure I thought "hum, pretty sure that's not like that" then forgot 20 seconds afterwards and copy-pasta happened.

server.js Outdated
if (context)
cmd.push('rc.context.' + context)
else
cmd.push('rc.report.next.filter')
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, shouldn't both apply? What is the logic for applying only the context filter if defined? When you call task on the commandline with a context set, it applies both the context filter and the report filter (next, list, whatever...).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A flawed one obviously :)

server.js Outdated
})
}

const spawn_tw = (opts) => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was about time to make a function for this :D Thanks for not being a pig like the original author of this code! ;-)

@evilham evilham assigned AnotherKamila and unassigned evilham Mar 2, 2018
@AnotherKamila AnotherKamila merged commit 0ffe0c1 into master Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants