10

Please do not mark and close this question as a duplicate of "Query closed questions" as the proposed duplicate does not answer the question of how to get the questions labeled [on hold] (rather than [closed]) -- as per comment posted by NormalHuman.

I would like to get all the questions that are currently put "on hold". These questions are labeled with [on hold] at the end of the post title (Please see a NOTE at the bottom).

So far I have tried the following search keywords:

  • on hold: too general and displays over 1500+ results
  • "on hold": displays over 780+ results
  • [on-hold]: displays 95 results. I was really hoping this tag would give me the expected result but it did not. It was showing all the posts that were suggested with "on-hold" tag while submission.

Here are few example questions that have [on hold] at the end of the post title (Please see a NOTE at the bottom): (Note: After 5 days these will be labeled with "[closed]")

  1. careers tools are too limited to search for candidates [on hold]

  2. Why are Stack Overflow people nice? [on hold]

  3. How to avoid infinite activity crash on Android? [on hold]

How should I get the questions just like the above ones i.e. labeled with [on hold] in their title not mixed with anything else?

NOTE: The question title is usually the actual page title (<title>....</title>) for most of the posts BUT in case of "on hold" (and may be "closed", "duplicate") it's not true. So, its "actual page title" vs "post title". I learned something new here. Thanks to Patrick Hofman(see comment below) for this find.

17
  • 1
    meta.stackexchange.com/questions/186906/…
    – random
    Commented Aug 1, 2015 at 2:54
  • 2
    possible duplicate of Query closed questions
    – random
    Commented Aug 1, 2015 at 2:55
  • 3
    @random The proposed duplicate does not answer the question of how to get the questions labeled [on hold] (rather than [closed]).
    – user259867
    Commented Aug 1, 2015 at 2:58
  • @random my question is about finding questions currently "[on hold]" in their title tag... Commented Aug 1, 2015 at 2:59
  • @NormalHuman Thanks but someone just marked it duplicate again with the post random pointed earlier... can u please help Commented Aug 1, 2015 at 3:04
  • meta.stackexchange.com/questions/10582/… it is not part of the title to search
    – random
    Commented Aug 1, 2015 at 3:32
  • You cannot search by who closed a question, even if they are moderators
    – random
    Commented Aug 1, 2015 at 3:32
  • @random I do not need to know "who closed the question" please click on those example links in my post to see what I mean. I need to get list of questions that are currently active with "[on hold]" label in their title. Commented Aug 1, 2015 at 3:34
  • You specifically say you want to search for those questions closed by moderators, not just closed, but by moderators
    – random
    Commented Aug 1, 2015 at 3:37
  • @random "on hold" is "closed"? is that because I said "on hold" by moderators? IF yes, I removed that reference now from the post Commented Aug 1, 2015 at 3:53
  • 3
    On hold is indeed closed. After two days it gets labeled differently in the UI, but in the back nothing changes. And the label is not in the actual title so you need to search for closed question that have been closed less than two days ago. Commented Aug 1, 2015 at 6:11
  • Why do you want to know? Many of them are in the reopen queue, but if they haven't been edited since they were put on hold they will not be in the queue. Commented Aug 1, 2015 at 6:51
  • Also, a dupe is not defined by current answers alone. If the duped question can potentially answers your question then it's still a dupe :)
    – James
    Commented Aug 1, 2015 at 12:09
  • @PatrickHofman Thank you. I agree that "on hold" is equivalent of "closed" BUT there is a 5 days period before it is labeled as "closed". Also, the reason I said "on hold label is in the title" because it is at the end of post title which usually is the "actual title" but apparently not in this case. So, its "actual title" vs "post title". I learned something new here. Commented Aug 1, 2015 at 12:53
  • 1
    You could use closed:1 active:2d for closed questions which last activity was less than two days.
    – Braiam
    Commented Aug 1, 2015 at 16:00

1 Answer 1

11

There are 3 possible ways to get that information, some are less precise than the other but each of them can be useful depending on your specific requirement or use case.

Search

The search capabilites of the Stack Exchange sites don't have the possiblity to search for ALL on-hold questions because the status on-hold is not differentiated from closed in the search engine.

If you are interested in the recent/new questions that are on hold you could use the search query:

closed:yes created:5d.. duplicate:no migrated:no

but that only works for questions asked in the last 5 days.

Stack API

To get the results you are after you need to leverage the Stack API which I have used in the included and runnable code snippet:

(function () {
  var api = {
    url: 'https://api.stackexchange.com/2.2/',
    endpoint: 'search/advanced',
    params: { 
      site: 'stackoverflow',
      pagesize: 100,
      order: 'desc',
      sort: 'activity',
      closed: 'True',
      migrated: 'False',
      Filter: '!Pw)kIARMuFW9bQ0Mxv)LqDCFAFq9fY'
      }
    };
    
    
  function createUrl(ap) {
    var ep = ap.url + ap.endpoint +'?',
     nv = [];
    $.each(ap.params, function (k,v) {
       nv.push(k + '=' + v);
    });
    console.log(ep + nv.join('&'));
    return ep + nv.join('&');
  }
 
  function enableLoad(func) {
    $('#load').show();
    $('#load').one('click', func);
  }
   
  function load(page) {
    console.log(page);
    api.params.page = page;
    $('#load').hide();
    $.get(createUrl(api), function (data) {
      var i, 
          list = $('#onhold'),
          next;
      for(i = 0; i < data.items.length; i = i +1) {
        if (typeof data.items[i].closed_details !== 'undefined' &&
            data.items[i].closed_details.on_hold) {
          list.append(
            $('<div></div>').append(
            $('<a></a>')
              .attr('href', data.items[i].link)
              .html(data.items[i].title)
            ));
        }
      }
      if (data.has_more) {
        next = function () { load(page + 1); };
        if (data.backoff !== undefined) {
          window.setTimeout( function () {
              enableLoad(next);
            }, 
            data.items.backoff * 1000);  
        } else {
            enableLoad(next);
        }
      } else {
        $('#load').hide(); 
      }
    });
  }
  
  load(1);
}());
#onhold div {
  overflow:hidden;
  text-overflow: ellipsis;
  white-space:nowrap;
  }

#load {
  padding: 1em;
  text-align: center; 
  cursor: pointer
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="error" style="display:none">
</div>
<div id="onhold">
  
</div>
<div id="load" style="display:none">
 Click to load more ...
</div>

This works by using the search/advanced endpoint, iterating over the results and check if in the subtype closed_details the field on_hold is true.

In that case I add a link to the question in the result. As the results are paged you have to click load more to load the next batch.

The Stack Exchange Data Explorer

One other option that could work once a week is to query SEDE just after the refresh (normally on Monday morning around 3:00 UTC). The following query could help with that:

declare @lastupdate datetime
select @lastupdate =  create_date 
from sys.databases
where database_id = db_id()

select [postid] as [Post Link]
from posthistory
where creationdate > dateadd(d, -5, @lastupdate)
and posthistorytypeid = 10 -- close

At posting this query returned 3,586 rows for Stack Overflow.

2
  • 1
    This answer solves my problem. Thank you for the SEDE query. Commented Aug 1, 2015 at 12:17
  • I got perfect result by modifying your options as - closed:yes created:2d duplicate:no migrated:no Commented Aug 1, 2015 at 20:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .