Skip to content

buscador de usuarios por nombre en github#41

Open
codemcu wants to merge 6 commits intomasterfrom
githubSearch
Open

buscador de usuarios por nombre en github#41
codemcu wants to merge 6 commits intomasterfrom
githubSearch

Conversation

@codemcu
Copy link
Copy Markdown
Collaborator

@codemcu codemcu commented Dec 12, 2018

No description provided.

@codemcu codemcu requested a review from UlisesGascon December 12, 2018 16:35
Copy link
Copy Markdown
Contributor

@UlisesGascon UlisesGascon left a comment

Choose a reason for hiding this comment

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

@codemcu, como te dije en #39. Estas en otro nivel y el grado de exigencia es mayor. Dicho esto, el código es elegante y funciona bien, aunque tienes un par de problemas en el HTML. (título del documento y gestión de imágenes transparentes). Me gusto mucho que incluyeras el Score

Dos cosas importantes... DRY y KISS. Estas haciendo dos llamadas AJAX para averiguar los followers y followings... cuando realmente lo podrías sacar la información haciendo una única llamada a su perfil https://api.github.com/users/ y evitando que rápidamente sobrepase el límite.

Espero un refactor 🕶

captura de pantalla 2018-12-14 a las 15 13 52

background: #355C7D"*/

body {
/*background-color: #F8B195;*/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ El código comentado... sobra :trollface:

width: 620px;
margin: 0 auto 0;
list-style-type: none;
/*background-color: #355C7D;*/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ El código comentado... sobra :trollface:


} else {

if (document.querySelector('ul') !== null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mete este selector en una variable

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍


loadAjax(`https://api.github.com/search/users?q=${text}+in%3Afullname&type=Users`)
.then(getNetwork)
.catch(error => console.log(error));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gestiona el error de forma visual también

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

he metido try/catch pero como console.log, por ahora...


if ($event.code === 'Enter' && $event.isTrusted) {

if (input.value.trim() === '') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No necesitas === "" podrías hacer !input.value.trim() o simplemente input.value.trim() que sería más legible

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

const p = document.createElement('P');
container.appendChild(p);
p.textContent = 'Please enter username';
return false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why?


users.forEach(function (item) {

const followers = new Promise( (resolve, reject) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

followersy followings son lo mismo con distintas urls. DRY!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nadie gestiona los errores... 🤦‍♂️

getFollowings(followings, div);
}

function getFollowers (followers, div) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

getFollowers y getFollowings son lo mismo con distinto texto y target.... DRY!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

async/await al rescate!. Aparte de mi despiste de followers y following en /user

Copy link
Copy Markdown
Contributor

@UlisesGascon UlisesGascon left a comment

Choose a reason for hiding this comment

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

Feedback

  • Muy bien por usar async/await
  • El código está algo descuidado, pero nada que un buen reactor no ayude a solucionar :trollface:
  • Me gusto mucho la idea del buscador! 👏
  • Estaría bien apoyar un poco al usuario cuando se esperan datos o no tenemos información que mostrar xD

🌟 Me gusta el diseño y que aparezcan todas las coincidencias!

captura de pantalla 2019-01-15 a las 16 43 17

Bugs

  • Qué pasa cuando alcanzas el límite?
  • No hay spinners ni similar...

reject(response.json());
}
})
.catch(error => console.log(error));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aqui haces un return raro...

input.addEventListener('keyup', searchUser, false);
const container = document.querySelector('.container');

async function searchUser($event) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

el naming de $event fuera de angular.. no es muy extendido ;-)

@@ -0,0 +1,112 @@
(function () {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

podría ser arrow...

try {
if ($event.code === 'Enter' && $event.isTrusted) {

if (!input.value.trim()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Esto lo reutilizas luego como text..

document.querySelector('ul').remove();
}

const text = input.value.trim();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ cuidado con el Hoisting


} else {

const isUl = document.querySelector('ul') !== null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

es raro como manejas este condicional y su contexto con document.querySelector('ul') e isUl


const resArray = data.items;

resArray.forEach(async function (item) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no es mas sencillo un Promise.All()?

@UlisesGascon UlisesGascon mentioned this pull request Jan 15, 2019
46 tasks
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.

2 participants