use of org.mamute.model.Question in project mamute by caelum.
the class FlaggableDAOTest method should_get_count_of_questions_with_two_flags.
@Test
public void should_get_count_of_questions_with_two_flags() throws Exception {
Question other = question(author, java);
addFlags(question, 10, author);
addFlags(other, 1, author);
session.save(java);
session.save(question);
session.save(other);
int count = flaggables.flaggedButVisibleCount(Question.class);
assertEquals(1, count);
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionBuilder method build.
public Question build() {
QuestionInformation questionInformation = informationBuilder.withTitle(title).withDescription(description).with(author).withTags(tags).withComment(comment).build();
Question q = new Question(questionInformation, author);
setId(q, id);
clear();
return q;
}
use of org.mamute.model.Question in project mamute by caelum.
the class IndexSyncJob method execute.
public void execute() {
new Thread(new Runnable() {
@Override
public void run() {
Session session = factory.getInstance().openSession();
try {
QuestionDAO questions = new QuestionDAO(session, generateUser());
long pages = questions.numberOfPages();
long total = 0;
LOGGER.info("Syncing questions!");
for (int i = 0; i < pages; i++) {
List<Question> q = questions.allVisible(i);
index.indexQuestionBatch(q);
total += q.size();
}
LOGGER.info("Synced " + total + " questions");
} finally {
session.close();
}
}
}).start();
}
use of org.mamute.model.Question in project mamute by caelum.
the class ListController method withTag.
@Get
public void withTag(String tagName, Integer p, boolean semRespostas) {
Integer page = getPage(p);
Tag tag = tags.findByName(tagName);
if (tag == null) {
result.notFound();
return;
}
List<Question> questionsWithTag = questions.withTagVisible(tag, page, semRespostas);
result.include("totalPages", questions.numberOfPages(tag));
result.include("tag", tag);
result.include("recentTags", recentTagsContainer.getRecentTagsUsage());
result.include("questions", questionsWithTag);
result.include("currentPage", page);
result.include("hasAbout", tags.hasAbout(tag));
if (semRespostas) {
result.include("unansweredActive", true);
result.include("noDefaultActive", true);
result.include("unansweredTagLinks", true);
}
}
use of org.mamute.model.Question in project mamute by caelum.
the class ListController method top.
@Get
public void top(String section) {
Integer count = 35;
List<String> tabs = asList("voted", "answered", "viewed");
if (!tabs.contains(section)) {
section = tabs.get(0);
result.redirectTo(this).top(section);
return;
}
DateTime since = DateTime.now().minusMonths(2);
List<Question> top = questions.top(section, count, since);
if (top.isEmpty()) {
result.notFound();
return;
}
result.include("tabs", tabs);
result.include("section", section);
result.include("questions", top);
result.include("currentUser", loggedUser);
}
Aggregations