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

feat(snippets): filter by language #402

Merged
merged 4 commits into from
Dec 4, 2023
Merged

Conversation

wJoenn
Copy link
Collaborator

@wJoenn wJoenn commented Dec 3, 2023

Summary of changes and context

closes #264

None selected :
image

Go selected :
image

Mobile
image

Sanity checks

  • Linters pass
  • Tests pass
  • Related GitHub issues are linked in the description

@wJoenn wJoenn force-pushed the feat/snippets/filter-by-language branch from aaadfe5 to 437f48b Compare December 3, 2023 18:59
@wJoenn wJoenn force-pushed the feat/snippets/filter-by-language branch from 437f48b to 5f43682 Compare December 3, 2023 19:00
@wJoenn wJoenn force-pushed the feat/snippets/filter-by-language branch from 5f43682 to 0232e6d Compare December 3, 2023 19:01
Copy link
Owner

@pil0u pil0u left a comment

Choose a reason for hiding this comment

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

C'est cool, bonne idée 👍

J'aurais préféré que les images soient toutes de la même taille, mais ça peut se fixer ultérieurement

app/assets/images/languages/sql.png Outdated Show resolved Hide resolved
@@ -8,6 +8,10 @@ def show
@snippet = Snippets::Builder.call(language: current_user.favourite_language)
@snippets = Snippet.includes(:user, :reactions).where(day: @day, challenge: @challenge).order(created_at: :desc)

@language = params[:language]
@languages = @snippets.pluck(:language).uniq.sort
Copy link
Owner

Choose a reason for hiding this comment

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

@snippets.distinct.order(:language).pluck(:language), tout dans la requête

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

pluck c'est une requete SQL ?
Je pensais que c'etait juste du ruby du coup j'ai pas pensé a opti

Copy link
Owner

Choose a reason for hiding this comment

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

En fait le premier @snippets retourne un objet ActiveRecord, donc tu peux lui appliquer les méthodes associées. ActiveRecord emprunte pas mal de noms de méthode de Ruby, ça peut arriver de confondre

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

irb(main):005> s.distinct.order(:language).pluck(:language)
/home/joenn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-mini-profiler-3.1.1/lib/patches/db/pg.rb:51:in `prepare': PG::InvalidColumnReference: ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list (ActiveRecord::StatementInvalid)
LINE 1: ...ay" = $1 AND "snippets"."challenge" = $2 ORDER BY "snippets"...
                                                             ^

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

J'arrives pas a faire avec ActiveRecord et j'ai plus le temps de regarder sorry

app/controllers/snippets_controller.rb Outdated Show resolved Hide resolved
app/controllers/snippets_controller.rb Show resolved Hide resolved
app/views/snippets/show.html.erb Outdated Show resolved Hide resolved
app/views/snippets/show.html.erb Outdated Show resolved Hide resolved
app/views/snippets/show.html.erb Outdated Show resolved Hide resolved
@wJoenn
Copy link
Collaborator Author

wJoenn commented Dec 3, 2023

@pil0u Tous les logos ont pas le meme aspect ratio donc on pourrait pas les avoir tous a la meme taille sans en deformer certains 🤔
Ce que j'ai fais c'est qu'il aient tous la meme hauteur plutot que la meme largeur du coup

@pil0u
Copy link
Owner

pil0u commented Dec 3, 2023

C'est ce que je voulais dire par "pas la même taille", ça aurait été bien d'avoir que des images carrées. C'est bien avec la hauteur qu'il faut jouer oui 👍

@pil0u pil0u merged commit bd3e6f0 into main Dec 4, 2023
5 checks passed
@pil0u pil0u deleted the feat/snippets/filter-by-language branch December 4, 2023 08:09
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.

Filtrer la liste des snippets par langage
3 participants