Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit 0adbef9

Browse files
committed
General Updates
Changes of syntax and warnings.
1 parent ea32983 commit 0adbef9

39 files changed

+232
-120
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ A blazingly fast Stack Overflow clone running the real Stack Exchange dataset.
44

55
**NOTE: The repository is no longer being actively maintained by the Dgraph team. If something is broken, we'd happily accept a pull request from you, but won't fix anything ourselves.**
66

7+
**Update: I'll (MichelDiz) start a kind of "support" for this PJ, so right now I'm on Windows and I will create a Branch
8+
just for my tests. Some things may be different on other systems. I will not change anything drasticly on this branch, I will only modify some syntax changes and give some tips on how to handle this project. For this branch, read the file "syntax_changes.txt ".
9+
710
[Live](https://graphoverflow.dgraph.io)
811

912
## Running locally

app/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ app.get("/api/current_user", (req, res) => {
3434
return;
3535
}
3636

37-
findUserByUID(req.user._uid_)
37+
findUserByUID(req.user.uid)
3838
.then(user => {
3939
console.log("user found", user);
4040
res.json(user);

app/auth.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { runQuery, getEndpointBaseURL } from "./helpers";
55
function createUser(accessToken, displayName, GitHubID) {
66
console.log("creating user...", accessToken);
77
const query = `
8-
mutation {
8+
{
99
set {
1010
<_:user> <DisplayName> "${displayName}" .
1111
<_:user> <GitHubAccessToken> "${accessToken}" .
@@ -36,7 +36,7 @@ export function findUserByUID(uid) {
3636
const query = `
3737
{
3838
user(func: uid(${uid})) {
39-
_uid_
39+
uid
4040
Reputation
4141
DisplayName
4242
CreationDate
@@ -56,14 +56,14 @@ export function findUserByUID(uid) {
5656
// configPassport configures passport using GitHub strategy
5757
export function configPassport(passport) {
5858
passport.serializeUser(function(user, done) {
59-
done(null, user._uid_);
59+
done(null, user.uid);
6060
});
6161

6262
passport.deserializeUser(function(id, done) {
6363
const query = `
6464
{
6565
user(func: uid(${id})) {
66-
_uid_
66+
uid
6767
Reputation
6868
CreationDate
6969
LastAccessDate
@@ -105,7 +105,7 @@ export function configPassport(passport) {
105105
const query = `
106106
{
107107
user(func: eq(GitHubID, ${profile.id})) {
108-
_uid_
108+
uid
109109
Reputation
110110
DisplayName
111111
CreationDate

app/client/src/components/AnswerComposer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class AnswerComposer extends React.Component {
2323
body={body}
2424
onUpdateBody={this.handleUpdateBody}
2525
onSubmitPost={() => {
26-
onCreateAnswer(question._uid_, body);
26+
onCreateAnswer(question.uid, body);
2727
this.setState({ body: "" });
2828
}}
2929
/>

app/client/src/components/AnswerItem.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import QuestionItemLastActivity from "./QuestionItemLastActivity";
77
import "../assets/styles/QuestionItem.css";
88

99
const QuestionItem = ({ question, history }) => {
10-
// console.log(question._uid_);
11-
const questionLink = `/questions/${question._uid_}`;
10+
// console.log(question.uid);
11+
const questionLink = `/questions/${question.uid}`;
1212
const questionScore = question.UpvoteCount - question.DownvoteCount;
1313

1414
return (

app/client/src/components/CommentItem.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import moment from "moment";
44
import marked from "marked";
55

66
const CommentItem = ({ comment, currentUser, onDeleteComment }) => {
7-
const isOwner = currentUser && comment.Author[0]._uid_ === currentUser._uid_;
7+
const isOwner = currentUser && comment.Author[0].uid === currentUser.uid;
88
const author = comment.Author[0];
99

1010
return (
@@ -19,7 +19,7 @@ const CommentItem = ({ comment, currentUser, onDeleteComment }) => {
1919
/>{" "}
2020
-{" "}
2121
<span className="comment-author-name">
22-
<Link to={`/users/${author._uid_}`}>
22+
<Link to={`/users/${author.uid}`}>
2323
{author.DisplayName}
2424
</Link>
2525
</span>{" "}
@@ -31,7 +31,7 @@ const CommentItem = ({ comment, currentUser, onDeleteComment }) => {
3131
href="#delete"
3232
onClick={e => {
3333
e.preventDefault();
34-
onDeleteComment(comment._uid_);
34+
onDeleteComment(comment.uid);
3535
}}
3636
>
3737
<i className="fa fa-close" />

app/client/src/components/CommentList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class CommentList extends React.Component {
3535
{commentsOnDisplay.map(comment => {
3636
return (
3737
<CommentItem
38-
key={comment._uid_}
38+
key={comment.uid}
3939
comment={comment}
4040
currentUser={currentUser}
4141
onDeleteComment={onDeleteComment}

app/client/src/components/History.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const History = ({ author, verb, timestamp }) => {
2121
? <div className="author-info">
2222
<div className="meta">
2323
<div className="author-name">
24-
<Link to={`/users/${author._uid_}`}>
24+
<Link to={`/users/${author.uid}`}>
2525
{author.DisplayName}
2626
</Link>
2727
</div>

app/client/src/components/Home.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Home extends React.Component {
7373
this.setState({ questions: [] });
7474
return;
7575
}
76-
query = getRecommendedQuestionsQuery(user._uid_);
76+
query = getRecommendedQuestionsQuery(user.uid);
7777
} else if (currentTab === ALL_TABS.TAB_RECENT) {
7878
query = `{ ${recentQuestionsQuery} }`;
7979
}

app/client/src/components/Post.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Post extends React.Component {
2525
}
2626

2727
componentWillReceiveProps(nextProps) {
28-
if (this.props.post._uid_ !== nextProps.post._uid_) {
28+
if (this.props.post.uid !== nextProps.post.uid) {
2929
this.setState({
3030
comments: nextProps.post.Comment,
3131
userUpvoted: nextProps.post.UserUpvoteCount === 1,
@@ -39,7 +39,7 @@ class Post extends React.Component {
3939
const { post } = this.props;
4040

4141
request
42-
.post(`/api/posts/${post._uid_}/comments`)
42+
.post(`/api/posts/${post.uid}/comments`)
4343
.send({ body })
4444
.then(res => {
4545
const { commentUID } = res.body;
@@ -63,10 +63,10 @@ class Post extends React.Component {
6363
const { comments } = this.state;
6464

6565
request
66-
.delete(`/api/posts/${post._uid_}/comments/${commentUID}`)
66+
.delete(`/api/posts/${post.uid}/comments/${commentUID}`)
6767
.then(() => {
6868
const newComments = comments.filter(comment => {
69-
return comment._uid_ !== commentUID;
69+
return comment.uid !== commentUID;
7070
});
7171
this.setState({
7272
comments: newComments
@@ -78,7 +78,7 @@ class Post extends React.Component {
7878
const { post } = this.props;
7979
const { userUpvoted, userDownvoted } = this.state;
8080

81-
request.post(`/api/posts/${post._uid_}/vote`).send({ type }).then(() => {
81+
request.post(`/api/posts/${post.uid}/vote`).send({ type }).then(() => {
8282
let scoreDelta = 0;
8383
if (type === "Upvote") {
8484
if (userDownvoted) {
@@ -113,7 +113,7 @@ class Post extends React.Component {
113113
scoreDelta = 1;
114114
}
115115

116-
request.delete(`/api/posts/${post._uid_}/vote`).send({ type }).then(() => {
116+
request.delete(`/api/posts/${post.uid}/vote`).send({ type }).then(() => {
117117
this.setState(prevState => {
118118
return {
119119
userUpvoted: false,
@@ -135,7 +135,7 @@ class Post extends React.Component {
135135
answer: post.Type === "Answer"
136136
})}
137137
>
138-
<div href="#" id={post._uid_} />
138+
<div href="#" id={post.uid} />
139139
{/* questions have title and answers don't */}
140140
{post.Title
141141
? <div className="post-title-container">

app/client/src/components/PostActions.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import React from "react";
22
import { Link } from "react-router-dom";
33

44
const PostActions = ({ post, currentUser, onDeletePost }) => {
5-
const isOwner = currentUser && post.Owner[0]._uid_ === currentUser._uid_;
5+
const isOwner = currentUser && post.Owner[0].uid === currentUser.uid;
66
return (
77
<div>
88
{isOwner
99
? <div>
10-
<Link to={`/posts/${post._uid_}/edit`}>edit</Link>
10+
<Link to={`/posts/${post.uid}/edit`}>edit</Link>
1111
<a
1212
href="#delete"
1313
onClick={e => {
1414
e.preventDefault();
15-
onDeletePost(post._uid_);
15+
onDeletePost(post.uid);
1616
}}
1717
>
1818
Delete

app/client/src/components/Question.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Question extends React.Component {
5050
const { user } = this.props;
5151
let currentUserUID;
5252
if (user) {
53-
currentUserUID = user._uid_;
53+
currentUserUID = user.uid;
5454
}
5555
const query = getQuestionQuery(questionUID, currentUserUID);
5656

app/client/src/components/QuestionItem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import QuestionItemLastActivity from "./QuestionItemLastActivity";
77
import "../assets/styles/QuestionItem.css";
88

99
const QuestionItem = ({ question, history }) => {
10-
const questionLink = `/questions/${question._uid_}`;
10+
const questionLink = `/questions/${question.uid}`;
1111
const questionScore = question.UpvoteCount - question.DownvoteCount;
1212

1313
return (

app/client/src/components/QuestionItemLastActivity.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const QuestionItemLastActivity = ({ question }) => {
1717
<div>
1818
asked {moment(questionCreatedAt).fromNow()} by{" "}
1919
<Link
20-
to={`/users/${owner._uid_}`}
20+
to={`/users/${owner.uid}`}
2121
onClick={e => {
2222
e.stopPropagation();
2323
}}
@@ -37,7 +37,7 @@ const QuestionItemLastActivity = ({ question }) => {
3737
answered {moment(lastAnswerCreatedAt).fromNow()} by{" "}
3838
{lastAnswerOwner
3939
? <div>
40-
<Link to={`/users/${lastAnswer.Owner[0]._uid_}`}>
40+
<Link to={`/users/${lastAnswer.Owner[0].uid}`}>
4141
{lastAnswerOwner.DisplayName || "no_username"}
4242
</Link>{" "}
4343
<span className="reputation">

app/client/src/components/QuestionLayout.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const QuestionLayout = ({
8686
{answers.map(answer => {
8787
return (
8888
<Post
89-
key={answer._uid_}
89+
key={answer.uid}
9090
post={answer}
9191
currentUser={currentUser}
9292
onDeletePost={onDeletePost}

app/client/src/components/QuestionList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const QuestionList = ({ questions }) => {
66
return (
77
<ul className="list-unstyled question-list">
88
{questions.map(question => {
9-
return <QuestionItem question={question} key={question._uid_} />;
9+
return <QuestionItem question={question} key={question.uid} />;
1010
})}
1111
</ul>
1212
);

app/client/src/components/RelatedQuestionList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ const RelatedQuestionList = ({ questions }) => {
55
return (
66
<ul className="list-unstyled">
77
{questions.map(question => {
8-
const questionLink = `/questions/${question._uid_}`;
8+
const questionLink = `/questions/${question.uid}`;
99
const questionScore = question.UpvoteCount - question.DownvoteCount;
1010

1111
return (
12-
<li className="related-question-item" key={question._uid_}>
12+
<li className="related-question-item" key={question.uid}>
1313
<Link to={questionLink}>
1414
<span className="related-question-score">
1515
{questionScore}

app/client/src/components/SearchResultAnswerItem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const SearchResultAnswerItem = ({ answer, searchTerm, searchTermWords }) => {
1111
return null;
1212
}
1313

14-
const questionLink = `/questions/${answer.question[0]._uid_}#${answer._uid_}`;
14+
const questionLink = `/questions/${answer.question[0].uid}#${answer.uid}`;
1515
const score = answer.UpvoteCount - answer.DownvoteCount;
1616

1717
return (

app/client/src/components/SearchResultList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const SearchResultList = ({ posts, searchTerm, searchTermWords }) => {
1313
question={post}
1414
searchTerm={searchTerm}
1515
searchTermWords={searchTermWords}
16-
key={post._uid_}
16+
key={post.uid}
1717
/>
1818
);
1919
} else {
@@ -22,7 +22,7 @@ const SearchResultList = ({ posts, searchTerm, searchTermWords }) => {
2222
answer={post}
2323
searchTerm={searchTerm}
2424
searchTermWords={searchTermWords}
25-
key={post._uid_}
25+
key={post.uid}
2626
/>
2727
);
2828
}

app/client/src/components/SearchResultQuestionItem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const SearchResultQuestionItem = ({
1010
searchTerm,
1111
searchTermWords
1212
}) => {
13-
const questionLink = `/questions/${question._uid_}`;
13+
const questionLink = `/questions/${question.uid}`;
1414
const questionScore = question.UpvoteCount - question.DownvoteCount;
1515

1616
return (

app/client/src/components/Tag.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class Tag extends React.Component {
103103
<ul className="list-unstyled">
104104
{relatedTags.map(tag => {
105105
return (
106-
<li key={tag._uid_}>
106+
<li key={tag.uid}>
107107
<span className="tag">
108108
<Link to={`/tags/${tag.TagName}`}>
109109
{tag.TagName}

app/client/src/components/TopTagList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const TopTagList = ({ tags }) => {
1111
<ul className="tag-list">
1212
{tags.map(tag => {
1313
return (
14-
<li className="tag-item" key={tag._uid_}>
14+
<li className="tag-item" key={tag.uid}>
1515
<span className="tag">
1616
<Link to={`/tags/${tag.TagName}`}>
1717
{tag.TagName}{" "}

app/client/src/components/TopUserItem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const TopUserItem = ({ user }) => {
99
<div className="top-user-item">
1010
<div className="info-row">
1111
<div className="info">
12-
<Link to={`/users/${user._uid_}`} className="username">
12+
<Link to={`/users/${user.uid}`} className="username">
1313
{user.DisplayName}
1414
</Link>
1515
<p className="about-me">

app/client/src/components/TopUserList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const TopUserList = ({ users }) => {
1212
<ul className="top-user-list">
1313
{users
1414
? users.map(user => {
15-
return <TopUserItem key={user._uid_} user={user} />;
15+
return <TopUserItem key={user.uid} user={user} />;
1616
})
1717
: <div>No ranking available. Not enough recent acitivities.</div>}
1818
</ul>

app/client/src/components/UserActions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const UserActions = ({ onLogout, user }) => {
55
return (
66
<div className="actions">
77
<div className="user">
8-
<Link to={`/users/${user._uid_}`}>
8+
<Link to={`/users/${user.uid}`}>
99
{user.DisplayName}
1010
</Link>
1111
</div>

app/client/src/components/UserPostItem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Link } from "react-router-dom";
33

44
const UserPostItem = ({ post }) => {
55
const score = post.upvoteCount - post.downvoteCount;
6-
const questionLink = `/questions/${post._uid_}`;
6+
const questionLink = `/questions/${post.uid}`;
77

88
return (
99
<li className="user-post-item">

app/client/src/components/UserPostList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const UserPostList = ({ posts }) => {
66
return (
77
<ul className="list-unstyled">
88
{posts.map(post => {
9-
return <UserPostItem key={post._uid_} post={post} />;
9+
return <UserPostItem key={post.uid} post={post} />;
1010
})}
1111
</ul>
1212
);

0 commit comments

Comments
 (0)