JanitorTags: Most common tags with short, long, or missing excerpt or wiki

1

Please login or register to vote for this query.

(click on this box to dismiss)

Lists the most commonly used tags with empty/missing/short tag wikis (wiki or excerpt). Can also identify tag wikis that are over a specified length. Enter -1 for all parameters to match all tags. Tags that have been synonymized are excluded.

User Experience

Q&A for user experience researchers and experts

-- Wiki excerpts have to have between 20 and 460 characters.
-- Full tag wikis have to have at least 30 characters.

-- MaxBodyLength: Body shorter than "Set to 0 or -1 to disable"
declare @max_body_len int = ##MaxBodyLength:int?0##
-- MaxExcerptLength: or excerpt shorter than "Set to 0 or -1 to disable"
declare @max_excerpt_len int = ##MaxExcerptLength:int?1##
-- MinBodyLength: or body longer than "Set to -1 to disable"
declare @min_body_len int = ##MinBodyLength:int?12000##
-- MinExcerptLength: or excerpt longer than "Set to -1 to disable"
declare @min_excerpt_len int = ##MinExcerptLength:int?-1##
-- PlotMinimum: Plot: Start at
declare @plot_min int = ##PlotMinimum:int?1##
-- Bin: Plot: Bin size
declare @bin int = ##Bin:Int?1##
-- BinCount: Plot: Number of bins "Maximum 999"
declare @bin_count int = ##BinCount:int?20##

select t.Count,
    t.TagName,
    coalesce(len(pe.Body),0) as ExcerptLen,
    coalesce(len(pw.Body),0) as WikiLen,
    pe.CreationDate,
    -- This stuff isn't that interesting:
    ts.TargetTagName as SynonymTarget
    --max(ese.Id) as ExcerptSuggestedEdit,
    --max(wse.Id) as WikiSuggestedEdit
into #TagList
from Tags t
left join Posts pe on pe.Id = t.ExcerptPostId
left join Posts pw on pw.Id = t.WikiPostId
left join TagSynonyms ts on ts.SourceTagName = t.TagName
--left join SuggestedEdits ese on pe.Id = ese.PostId and len(pe.Body) = 0
--left join SuggestedEdits wse on pw.Id = wse.PostId and len(pw.Body) = 0
where -- match everything but synonyms if all parameters are disabled
    ((@max_body_len <= 0 and @max_excerpt_len <= 0
      and @min_body_len = -1 and @min_excerpt_len = -1)
      or coalesce(len(pe.Body),0) < @max_excerpt_len -- short excerpt
      or coalesce(len(pw.Body),0) < @max_body_len    -- short wiki
      or len(pe.Body) > nullif(@min_excerpt_len,-1)  -- long excerpt
      or len(pw.Body) > nullif(@min_body_len,-1))    -- long wiki
     and ts.ApprovalDate is null -- exclude tags that are synonyms
--group by t.Count, t.TagName, pe.Body, pw.Body, pe.CreationDate, ts.TargetTagName

-- Make a list of integers
-- Based on http://stackoverflow.com/questions/2157282/generate-days-from-date-range/2157776#2157776
select num
into #Integers
from
 (select @plot_min + (a.a + (10 * b.a) + (100 * c.a)) * @bin as num
  from (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as a
    cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as b
    cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c
 ) a
where a.num <= (select max(Count)
                from #TagList
                where Count < (@plot_min + @bin*@bin_count))

select Count, TagName, ExcerptLen, WikiLen, CreationDate, SynonymTarget
--    ExcerptSuggestedEdit as [Suggested Edit Link],
--    WikiSuggestedEdit as [Suggested Edit Link]
from #TagList
order by -- show tags that have a wiki but no excerpt first
    case when WikiLen > 0 and ExcerptLen = 0 then 0 else 1 end,
    Count desc,
    ExcerptLen asc,
    WikiLen asc,
    TagName

select num as [Number of questions],
    count(Count) as [Number of tags with this many questions]
from #TagList
right join #Integers on Count between num and (num+@bin-1)
group by num
order by num

select getdate() as 'Time of query'

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results