Skip to content
This repository was archived by the owner on May 9, 2021. It is now read-only.

Conversation

@akanevsky
Copy link

I implemented a tag feature. This resolves #23. Please see the tags.md file in my branch for a full description.

Here are some screenshots...

Project activity feed with tags:

project-activity-feed-with-tags

Issue list with filter and tags:

open-issue-with-filter-and-tags

Issue with tags:

issue-with-tags

Tag administration homepage:

administration-index

Edit tag screen:

administration-edit-1

Edit tag screen with color picker:

administration-edit-2

Hope you enjoy, and send some feedback.

@baurez
Copy link

baurez commented Dec 5, 2013

Hi,
I installed on my version and everything seams OK

Very good feature :)

@brunocascio
Copy link

Hi !

I found an error where search with multiple tags.

I see this query:

SELECT `projects_issues`.* FROM `projects_issues` 

LEFT JOIN `projects_issues_tags` 
    ON `projects_issues_tags`.`issue_id` = `projects_issues`.`id` 

LEFT JOIN `tags` 
    ON (`tags`.`id`  = `projects_issues_tags`.`tag_id`) 

WHERE `project_id` = '4' 
AND `tags`.`tag` = 'resolution:fixed'
AND `tags`.`tag` = 'status:open'

GROUP BY `projects_issues`.`id` 

ORDER BY `projects_issues`.`updated_at` DESC;

SQL not allowed multiples "where" filters for an clause join:

WHERE `project_id` = '4' 
AND `tags`.`tag` = 'resolution:fixed'
AND `tags`.`tag` = 'status:open'

And, why use "LEFT JOIN" and not "INNER JOIN" ?

"LEFT JOIN" not only return to the issues associated tags, but also those that are not associated with any.

@pixeline
Copy link

Hello,
@brunocascio you are right. The correct query should be

SELECT `projects_issues`.* FROM `projects_issues` 

 JOIN `projects_issues_tags` 
    ON `projects_issues_tags`.`issue_id` = `projects_issues`.`id` 

 JOIN `tags` 
    ON (`tags`.`id`  = `projects_issues_tags`.`tag_id`) 

WHERE `project_id` = '1' 
AND `tags`.`tag` IN('tagname1','tagname2')

GROUP BY `projects_issues`.`id` 
HAVING COUNT(DISTINCT `tags`.`tag`) = 2

ORDER BY `projects_issues`.`updated_at` DESC

I'm new to Laravel, but i'll try to submit a patch.

@pixeline
Copy link

Ok, i've found a workaround:

in app/application/controllers/project.php

From Line 77:

if ($tags || $sort_by != 'updated')
        {
            $issues = $issues
                ->join('projects_issues_tags', 'projects_issues_tags.issue_id', '=', 'projects_issues.id')
                ->join('tags', 'tags.id', '=', 'projects_issues_tags.tag_id');
        }

        $issues = $issues->where('project_id', '=', Project::current()->id);

        if ($assigned_to)
        {
            $issues = $issues->where('assigned_to', '=', $assigned_to);
        }

        if ($tags)
        {
            $tags_collection = explode(',', $tags);
            $tags_amount = count($tags_collection);
/*
            foreach (explode(',', $tags) as $tag)
            {
                if (substr($tag, -2) == ':*')
                {
                    $tags_collection[] = substr($tag, 0, strlen($tag) - 2) . ':%';
                    //$issues = $issues->where('tags.tag', 'LIKE', $tag);
                }
                else
                {
                    $tags_collection[] =$tag;
                    //$issues = $issues->where('tags.tag', '=', $tag);
                }
            }
*/

            $issues = $issues->where_in('tags.tag', $tags_collection);//->get();
        }

        $issues = $issues
            ->group_by('projects_issues.id')
            ->order_by($sort_by_clause, $sort_order);

        if($tags && $tags_amount>1){
            // L3
            $issues = $issues->having(DB::raw('COUNT(DISTINCT `tags`.`tag`)'),'=',$tags_amount);
            // L4 $issues = $issues->havingRaw("COUNT(DISTINCT `tags`.`tag`) = ".$tags_amount);
        }

        $issues = $issues->get(array('projects_issues.*'));

@mikelbring mikelbring closed this May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants