nyyManni / ejira

Emacs JIRA integration
GNU General Public License v3.0
255 stars 36 forks source link

Only sync issues for specific user #20

Closed osktyn closed 4 years ago

osktyn commented 4 years ago

Is there a way (or "what is the way") to only ejira-update-my-projects for a specific assignee? Could really be for any property like type/status/assignee but my usercase is that I only want to keep issues related to me in my org-file.

Feel like a great project, thank you for your work so far.

MadEarl commented 4 years ago

As far as I can see, you need to redefine ejira-update-project. Change the lines like (format "project = '%s' and resolution = unresolved" id) and add assignee = currentUser() to the jql.

nyyManni commented 4 years ago

@MadEarl 's tip should do the trick. A function to update a set of issues by a user-provided jql would probably be something that ejira should provide, though.

ejira-update-project does a bit of extra-work to make sure both the client and the server agree which issues in the project are unresolved. If we only simply updated unresolved issues, a closed issue would never sync to the org-files.

The same would go for the assignee. If you only query with assignee = currentUser() ejira would not sync issues that were assigned to you during the previous sync but no longer are so.

osktyn commented 4 years ago

(format "project = '%s' and resolution = unresolved and assignee = currentUser()" id) made it work. Thank you @MadEarl and @nyyManni.

EDIT: (format "(project = '%s' and resolution = unresolved and assignee = currentUser()) or (project = '%s' and resolution = unresolved and reporter = currentUser())" id id) might be even better.

nightscape commented 4 years ago

Emacs noob here :wink: Is it possible to do this modification without forking the project and modifying it in the source code?

osktyn commented 4 years ago

@nightscape You can avoid the forking and git-usage by instead downloading and extracting the code, but modifying the code is necessary.

nightscape commented 4 years ago

@osktyn in that case I would prefer forking because then I can at least rebase my branch on this repo. @nyyManni do you have any plans to make the query template configurable via setq or so?

nyyManni commented 4 years ago

No forking should be needed in any case, as you can always just redefine the function in your emacs init file after ejira is loaded.

Making the query template configurable would probably make sense, but there is a catch which I mentioned in my first comment in this thread. The update process consists of two parts:

"project = '%s' and resolution = unresolved"
"project = '%s' and key in (%s) and resolution = done"

Which together make sure that there are no "hanging" tickets in the org-files that are not synced since the server considers them resolved.

I can make the two format strings configurable, but then they would always need to contain the correct number of %s's and in the correct order, which feels quite risky.

The proper way to do it would be:

  1. Do a query with "assignee = currentUser() and resolution = unresolved"
  2. Find all headings with :ejira_assigned:-tag
  3. Do another sync with the headings found in step 2.