Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

London10 | Seyyednavid Hejazijouybari | Full-Stack-Project-Assessment | Level 999 #365

Closed
wants to merge 71 commits into from

Conversation

seyyednavid
Copy link

No description provided.

@seyyednavid seyyednavid changed the title London10 | Seyyednavid Hejazijouybari | Full-Stack-Project-Assessment | Level 100,199,200 and 250 London10 | Seyyednavid Hejazijouybari | Full-Stack-Project-Assessment | Level 299 Aug 25, 2023
@seyyednavid seyyednavid changed the title London10 | Seyyednavid Hejazijouybari | Full-Stack-Project-Assessment | Level 299 London10 | Seyyednavid Hejazijouybari | Full-Stack-Project-Assessment | Level 999 Aug 27, 2023
Copy link
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generally looking really good, but I'd encourage you to spend more time thinking about making sure the names you use are really clear and meaningful.

throw new Error("Something went wrong!");
}
const data = await response.json();
getDeleteMessage(data.message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not super clear from the name what getDeleteMessage does - could you think of a more clear name to show what this means?

}
};

const voteDownHandler = async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very similar to the voteUpHandler - can you work out how to share their code in one function, rather than duplicate it?

const VideoForm = ({ getAllVideos }) => {
const [title, setTitle] = useState("");
const [url, setUrl] = useState("");
const [backendMessage, setBackendMessage] = useState("");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the backend message? Can you think of a more clear name for this, or add a comment explaining what it's for?

} else if (response.status === 409) {
const existingError = await response.json();
setErrorMessage(existingError.message);
} else if (response.status !== 201) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given you've been doing lots of === checks before, I'd more expect you to handle the === 201 case here, and for the else to be "all other status codes", rather than the other way around. Your core here works, but it's kind of surprising, which makes it slightly harder to read and work with. People are really good at spotting patterns, so breaking that pattern can be confusing.

Comment on lines +6 to +7
const [search, setSearch] = useState("");
const [videoSearch, setVideoSearch] = useState([]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not super clear from the naming what videoSearch is and how it's different from search - can you think of clearer names to make their differences and roles clear?

Or is there a way you could even get rid of one of the states, and not need them both?


useEffect(() => {
if (search === "") {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you've already searched for something, then get rid of the search term, what will be displayed?


CREATE TABLE videos (
id VARCHAR(255) PRIMARY KEY,
Date VARCHAR(255),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postgres has specific date types that are more suitable to use than VARCHAR(255), I'd recommend using one as it will allow you to do things like comparisons, or extracting a month, more easily in the future :)

CREATE DATABASE videos_recommendation;

CREATE TABLE videos (
id VARCHAR(255) PRIMARY KEY,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We typically use SERIAL as a type of ids, rather than VARCHARs - can you research SERIAL and work out what it does and why it's useful?

let filteredVideos = [...allVideos.rows];
// Apply search filter if search query is provided
if (search) {
filteredVideos = filteredVideos.filter((video) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do this filtering in SQL rather than in javascript? Also the sorting.

Both work, but doing so in SQL will be faster.

);
}
//Apply order filter
if (order === "desc") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're sorting on both the client side and the server side - do you need to do both? What are the advantages/disadvantages of doing it in each place?

seyyednavid and others added 29 commits October 11, 2023 15:21
Signed-off-by:  Seyyednavid Hejazijouybari <[email protected]>
Signed-off-by:  Seyyednavid Hejazijouybari <[email protected]>
Signed-off-by:  Seyyednavid Hejazijouybari <[email protected]>
Signed-off-by:  Seyyednavid Hejazijouybari <[email protected]>
Signed-off-by:  Seyyednavid Hejazijouybari <[email protected]>
Signed-off-by:  Seyyednavid Hejazijouybari <[email protected]>
Signed-off-by:  Seyyednavid Hejazijouybari <[email protected]>
Signed-off-by:  Seyyednavid Hejazijouybari <[email protected]>
@Dedekind561 Dedekind561 closed this Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants