@Test public void findRepostByTweets_Entity_複数_00() { Tweet twt1 = Tweet.findBySerialCode("twt-goro2").first(); Tweet twt2 = Tweet.findBySerialCode("twt-jiro1").first(); List<RepostBase> lst = RepostBase.findRepostByTweets(twt1, twt2).fetch(); assertThat(lst.size(), is(7)); // DBからの取得リストの並び保証なし }
@Test public void findRepostByTweets_Entity_複数_投稿者_00() { Tweet twt1 = Tweet.findBySerialCode("twt-goro2").first(); Tweet twt2 = Tweet.findBySerialCode("twt-jiro1").first(); Account acnt = Account.findByLoginName("goro_san").first(); List<RepostBase> lst = RepostBase.findRepostByTweets(twt1, twt2).contributor(acnt).fetch(); assertThat(lst.size(), is(5)); // DBからの取得リストの並び保証なし }
@Test public void findRepostByTweets_Entity_複数_投稿者_降順_00() { Tweet twt1 = Tweet.findBySerialCode("twt-goro2").first(); Tweet twt2 = Tweet.findBySerialCode("twt-jiro1").first(); Account acnt = Account.findByLoginName("goro_san").first(); List<RepostBase> lst = RepostBase.findRepostByTweets(twt1, twt2) .contributor(acnt) .orderBy(RepostBase.OrderBy.DATE_OF_REPOST_DESC) .fetch(); assertThat(lst.size(), is(5)); assertThat(lst.get(0).getItem().serialCode, is("twt-jiro1")); }
public void onStatus(twitter4j.Status status) { Logger.info(status.getUser().getName() + " : " + status.getText()); Tweet tweet = new Tweet(status); tweet.conformsToTerms = checkMatch(status); tweet.save(); if (tweet.conformsToTerms && esClient != null) { String json = DataObjectFactory.getRawJSON(status); json = json.replaceAll( "(\"geo\":\\{\"type\":\"Point\",\"coordinates\":)\\[([-0-9.,]*)\\]", "$1\"$2\""); // Logger.debug("geo mangled json"); // Logger.debug(json); IndexResponse response = esClient.prepareIndex("twitter", "tweet").setSource(json).execute().actionGet(); } }
public static Result list(int page, int pageSize) { Page<Tweet> currentPage = Tweet.page(page - 1, pageSize); // List<Tweet> tweets = Tweet.find.where().eq("conformsToTerms",true).orderBy("date // desc").findList(); StreamConfig config = getConfig(); String terms = config.listTermsAsString(); return ok(stream_result_list.render(currentPage, page, pageSize, terms)); }
// public static Result listTweet() { // return redirect(routes.Application.index()); // } public static Result listTweet() { List<Tweet> tweets = new ArrayList<Tweet>(); Tweet tweet1 = new Tweet(); tweet1.commentaire = "bla bla blza"; tweet1.username = "******"; tweet1.creationDate = new Date(); tweets.add(tweet1); Tweet tweet2 = new Tweet(); tweet2.commentaire = "re bla bla blza"; tweet2.username = "******"; tweet2.creationDate = new Date(); tweets.add(tweet2); if (request().accepts("text/html")) return ok(views.html.wall.render(tweets)); else if (request().accepts("application/json")) return ok(Json.toJson(tweets)); return badRequest(); // return ok(views.html.wall.render(tweets)); }