arteman (arteman) wrote in changelog,
arteman
arteman
changelog

[livejournal] r21976: LJSUP-12229 Rating of support tags

Committer: azateev
LJSUP-12229 Rating of support tags
U   trunk/cgi-bin/LJ/Support/Request/Tag.pm
U   trunk/htdocs/support/manage_tags.bml
Modified: trunk/cgi-bin/LJ/Support/Request/Tag.pm
===================================================================
--- trunk/cgi-bin/LJ/Support/Request/Tag.pm	2012-05-17 08:21:10 UTC (rev 21975)
+++ trunk/cgi-bin/LJ/Support/Request/Tag.pm	2012-05-17 09:06:19 UTC (rev 21976)
@@ -529,4 +529,50 @@
     }
 }
 
+# get_tags_ranking(): gets a list of support tags, sorted by frequency of usage
+# calling format:
+# get_tags_ranking($area, $threshold)
+# $area should be one of the following values ('all','jira-all','jira-fixed','jira-open')
+# returns a list of hashrefs.
+sub get_tags_ranking {
+    my ($area, $threshold) = @_;
+
+    $threshold = int $threshold;
+
+    my $dbr = LJ::get_db_reader();
+    my $rows = $dbr->selectall_arrayref(qq{
+            SELECT   name tagname,
+                     MIN(sptagid) mintagid,
+                     MIN(spcatid) mincatid,
+                     count(*) qty
+            FROM     supporttag LEFT JOIN supporttagmap
+            USING    (sptagid)
+            GROUP BY name
+            HAVING   qty >= $threshold
+            ORDER BY qty DESC
+        }, { Slice => {} });
+
+    my @res;
+    foreach my $row (@$rows) {
+        my $name = $row->{tagname};
+
+        my @tag_areas = qw( all );
+
+        if ( $name =~ /ljsv|ljsup|ljm/ ) {
+            push @tag_areas, 'jira-all';
+
+            if ( $name =~ /fixed/ ) {
+                push @tag_areas, 'jira-fixed';
+            } else {
+                push @tag_areas, 'jira-open';
+            }
+        }
+
+        next unless grep { $_ eq $area } @tag_areas;
+        push @res, $row;
+
+    }
+    return @res;
+}
+
 1;

Modified: trunk/htdocs/support/manage_tags.bml
===================================================================
--- trunk/htdocs/support/manage_tags.bml	2012-05-17 08:21:10 UTC (rev 21975)
+++ trunk/htdocs/support/manage_tags.bml	2012-05-17 09:06:19 UTC (rev 21976)
@@ -45,13 +45,15 @@
     if ($FORM{'rename'}) {
         my $sptagid = $FORM{'sptagid'};
         my $spcatid = $FORM{'spcatid'};
+        my $area    = $FORM{'everywhere'} ? 'checked' : '';
         my $name = LJ::Support::Request::Tag::tag_id_to_name($sptagid);
 
         my $ret = '<form method="POST">';
         $ret .= qq{New name: <input name="new_name" type="text" value="$name"/>};
         $ret .= '<br/>';
         $ret .= qq{<label for="everywhere">$ML{'.rename.everywhere'}</label>};
-        $ret .= qq{<input id="everywhere" type="checkbox" name="everywhere"/>};
+        $ret .= qq{<input id="everywhere" type="checkbox" name="everywhere"
+                    $area/>};
         $ret .= '<br/>';
         $ret .= qq{<label for="merge">$ML{'.rename.merge'}</label>};
         $ret .= qq{<input id="merge" type="checkbox" name="allowmerge"/>};

Tags: arteman, azateev, bml, livejournal, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments