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

fetches project id for every issue creation #5

Open
stevecrozz opened this issue Jan 19, 2016 · 4 comments
Open

fetches project id for every issue creation #5

stevecrozz opened this issue Jan 19, 2016 · 4 comments

Comments

@stevecrozz
Copy link
Member

Project_ids presumably don't change very often or ever, so it's not efficient to fetch the project_id every time we create an issue. But that's what we're doing. We should stop doing this and set the project_id once instead.

In order to not need a migration, we should make it set the project_id when saving the issue tracker (to make future errbits more efficient), and also fetch the project_id live (to keep already configured errbits working).

@stex
Copy link
Collaborator

stex commented Jan 20, 2016

It would definitely help if an errbit_plugin like an issue tracker could save additional data.
I was searching for such a way when I updated this plugin, but haven't found one except something like class variable usage as the fields cannot be altered from within a tracker instance.

An option might be to add another set of fields to errbit_plugin's IssueTracker, which are not shown in the UI, but rather meant to be filled by the plugin at certain points.

To avoid having to migrate old errbit installations, a mechanism like Cache.fetch for these fields might work which will return the value if the field exists and actually contains a value or execute a block/method instead (again while automatically setting the field if it exists).

internal_fields.fetch 'gitlab_project_id' do
    projects.detect { ... }
end

As a new tracker instance is created every time, it might also be a good idea to have an explicit setup (or similar) function which is called only when adding an issue tracker to an app instead of just checking for errors.

@stevecrozz
Copy link
Member Author

These sounds like some good ideas. I'd be very hesitant to break backwards compatibility with the issue tracker interface because that would mean new versions of every plugin. But I think this could be done without having to go down that road.

@quexpl
Copy link
Contributor

quexpl commented Apr 28, 2016

According to GitLab documentation (http://doc.gitlab.com/ce/api/projects.html#get-single-project)

Get a specific project, identified by project ID or NAMESPACE/PROJECT_NAME, which is owned by the authenticated user. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded, eg. /api/v3/projects/diaspora%2Fdiaspora (where / is represented by %2F).

So there is no need to fetch project id, we can pass project name with namespace to issue create method.

@stex
Copy link
Collaborator

stex commented May 1, 2016

Changing the create_issue method to use the project name instead of its id is a good idea.

However, I think the main problem is that the issue tracker is valided every time a new issue is created. This means, that we either have to remove all validations performed in errors or find a way to only call them when updating an app/setting up the tracker.
Currently, there doesn't seem to be a way for the tracker to differentiate between an initialization during its setup and an issue generation.

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

No branches or pull requests

3 participants