diff --git a/nebula/queries/interactive-complex-4.ngql b/nebula/queries/interactive-complex-4.ngql index ebc9d5474..1a5a8615d 100644 --- a/nebula/queries/interactive-complex-4.ngql +++ b/nebula/queries/interactive-complex-4.ngql @@ -1,12 +1,17 @@ -MATCH (person:Person)-[:KNOWS]-(:Person)<-[:POST_HAS_CREATOR]-(post:Post), (post)-[:HAS_TAG]->(`tag`:`Tag`) -WHERE id(person) == $personId AND post.Post.creationDate >= $startDate AND post.Post.creationDate < $endDate -WITH person, count(post) AS postsOnTag, `tag` -OPTIONAL MATCH (person)-[:KNOWS]-()<-[:POST_HAS_CREATOR]-(oldPost:Post), (oldPost)-[:HAS_TAG]->(`tag`) -WHERE oldPost.Post.creationDate < $startDate -WITH person, postsOnTag, `tag`, count(oldPost) AS cp -WHERE cp == 0 -RETURN - `tag`.`Tag`.name AS tagName, - sum(postsOnTag) AS postCount +MATCH (person:Person)-[:KNOWS]-(friend:Person)<-[:POST_HAS_CREATOR]-(post:Post)-[:HAS_TAG]->(`tag`:`Tag`) +WHERE id(person) == $personId +WITH DISTINCT `tag`.`Tag`.name AS tagName, post.Post.creationDate AS creationDate +WITH tagName, + CASE + WHEN creationDate >= $startDate AND creationDate < $endDate THEN 1 + ELSE 0 + END AS valid, + CASE + WHEN creationDate < $startDate THEN 1 + ELSE 0 + END AS inValid +WITH tagName, sum(valid) AS postCount, sum(inValid) AS inValidPostCount +WHERE postCount > 0 AND inValidPostCount == 0 +RETURN tagName, postCount ORDER BY postCount DESC, tagName ASC -LIMIT 10 +LIMIT 10 \ No newline at end of file diff --git a/nebula/queries/interactive-complex-7.ngql b/nebula/queries/interactive-complex-7.ngql index e1d7114fc..60e79db30 100644 --- a/nebula/queries/interactive-complex-7.ngql +++ b/nebula/queries/interactive-complex-7.ngql @@ -14,12 +14,15 @@ RETURN latestLike.likeTime AS likeCreationDate, id(latestLike.msg) AS messageId, CASE WHEN tags(latestLike.msg) == ["Post"] THEN - CASE WHEN size(latestLike.msg.imageFile) == 0 THEN latestLike.msg.content - ELSE latestLike.msg.imageFile + CASE WHEN size(latestLike.msg.`Post`.imageFile) == 0 THEN latestLike.msg.`Post`.content + ELSE latestLike.msg.`Post`.imageFile END ELSE latestLike.msg.`Comment`.content END AS messageContent, - latestLike.msg.`Comment`.creationDate AS messageCreationDate, + CASE WHEN tags(latestLike.msg) == ["Post"] THEN + latestLike.msg.`Post`.creationDate + ELSE latestLike.msg.`Comment`.creationDate + END as messageCreationDate, e IS NULL AS isNew ORDER BY likeCreationDate DESC,