11

I try to answer unanswered questions. When I read through comments, I always found that comments actually solved the problem.

examples:

  1. can this use case be ever worked out in ehcache?
  2. Abstract class as functional interface
  3. AngularJS: list all form errors

I found I wasted a lot of time to do my own filter for that. Any better way to do that?

5
  • 4
    You can't really filter out those questions. You can however, help everyone out, by handling questions which are answered in the comments correctly. TL;DR; don't be afraid to add answers to those questions which are already answered in the comments, giving proper attribution to the ideas
    – Matt
    Commented Jul 7, 2014 at 14:46
  • 1
    I read the link you shared. I will try to follow that practice. If everyone contribute in that manner, I think we can reduce number of unanswered questions.
    – hutingung
    Commented Jul 7, 2014 at 14:55
  • When I try to search, I can't find the answer. After posted, then I got related questions and useful answer's link - meta.stackoverflow.com/questions/251597/… and meta.stackoverflow.com/questions/252565/…. It might not filter unanswered questions with comments solved the issue but those practices can reduce number of these kind of unanswered question.
    – hutingung
    Commented Jul 7, 2014 at 14:58
  • 1
    This is all very good, but in the meantime, why isn't there a filter like comments:0 (the same way there is answers:0)? I would like such a filter to occasionally help out people who didn't even get a single response on their question (as this has happened to me as well).
    – smheidrich
    Commented Sep 9, 2015 at 13:14
  • 1
    @Matt could you post your comment as the answer to this question? (now for a double entendre: this is so meta lol) Commented Mar 20, 2017 at 19:12

1 Answer 1

3

You could use the Stack API to find questions with no answers and then loop of the results, skipping those questions that have a comment count greater then zero. That guarantees that the question isn't answered in the comments.

The following stack-snippet demonstrates how that could work out:

(function () {

  var q = document.getElementById('q'),
      next = document.getElementById('next'),
      p = 1,
      api = 'https://api.stackexchange.com/2.2',
      ep = '/questions/no-answers',
      query = 'order=desc&sort=activity&site=stackoverflow&filter=!9Z(-wv328';

  function createStats(item) {
     var stats = document.createElement('div');
         score = document.createElement('span');
     score.textContent = item.score;
     stats.appendChild(score);
     stats.className = 'stats';
     return stats;
  }
  
  function createUsercard(owner) {
    var user = document.createElement('div'),
        img = document.createElement('img'),
        a = document.createElement('a');
    img.src = owner.profile_image;
    a.href = owner.link;
    a.title = owner.display_name;
    a.appendChild(img);
    user.appendChild(a);
    user.className = 'user';
    return user;
  }
  
  function createSummary(item) {
    var summ = document.createElement('div'),
        h3 = document.createElement('h3'); 
        a = document.createElement('a');
    a.href = item.link;
    a.innerHTML = item.title;
    h3.appendChild(a);
    summ.className = 'summary';
    summ.appendChild(h3);
    summ.appendChild(createUsercard(item.owner));
    return summ;
  }

  function addQuestionCard(item) {
    var cont = document.createElement('div');
    cont.className = 'card';
    cont.appendChild(createStats(item));
    cont.appendChild(createSummary(item));
    q.appendChild(cont);
  }
  
  function mapQuestions(items) {
    var item;
    for(var i=0; i < items.length; i++) {
      item = items[i];
      if (item.comment_count === 0) {
        addQuestionCard(item);
      }
    }
  }
  
  function load(page) {
    var xhr = new XMLHttpRequest(),
        url = api + ep + '?' + query + '&page=' + page;
    xhr.open('GET', url);
    xhr.addEventListener('load', function() {
      var data = JSON.parse(xhr.responseText);
      if (data.items) {
        mapQuestions(data.items);
      }
      if (data.has_more === true) {
        setTimeout(
          function() {
            next.removeAttribute('disabled');
          }, 
          (data.backoff || 1) * 1000);
      }
    });
    next.setAttribute('disabled','disabled');
    xhr.send();
  }
  
  load(p);
  
  next.addEventListener(
    'click', 
    function() {
      load(p++);
    });
  
})()
.summary {
  width: 90%;
  float:left;
}
.summary h3 {
    font-size: 15px;
    line-height: 1.4;
    margin-bottom: .5em;
    margin: 0 0 0.5em;
}

.user {
  display: inline;
  width:32px;
  height:32px;
  float:right;
}

.user img {
  width:32px;
  height:32px;
}

.stats {
  width: 7%;
  float:left;
}

.card {
  float:left;
  clear:both;
  width:100%;
  margin-bottom: 1em;
}

button{
  float:left;
  clear:both;
}
<div id="q">
</div>
<button id="next" disabled="disabled">Next</button>

You could limit the resultset by adding extra criteria like tagged or creationdate but I leave that as an exercise for the reader.

You must log in to answer this question.

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