-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
aaadfe5
to
437f48b
Compare
437f48b
to
5f43682
Compare
5f43682
to
0232e6d
Compare
There was a problem hiding this 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
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"...
^
There was a problem hiding this comment.
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
@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 🤔 |
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 👍 |
Summary of changes and context
closes #264
None selected :
![image](https://private-user-images.githubusercontent.com/75388869/287542480-205167bd-f6a5-48de-ad3b-a8d486369e09.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTMzMDAsIm5iZiI6MTczOTM1MzAwMCwicGF0aCI6Ii83NTM4ODg2OS8yODc1NDI0ODAtMjA1MTY3YmQtZjZhNS00OGRlLWFkM2ItYThkNDg2MzY5ZTA5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA5MzY0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ3NzMwNGQzZGE5NTBkMzgwZTdmNTM3ZDlhNjM2ODRjZWYyMWM0YTc1M2E4ZTYyZDQ2YmVlZjU1ZjFhMTQzZWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.7lFIbx92tI2XzdDjQkI3smgCjmIeBcAoc1w5Gnra5QQ)
Go selected :
![image](https://private-user-images.githubusercontent.com/75388869/287542499-76f5240c-a37b-4e93-878d-4b05aa4c6713.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTMzMDAsIm5iZiI6MTczOTM1MzAwMCwicGF0aCI6Ii83NTM4ODg2OS8yODc1NDI0OTktNzZmNTI0MGMtYTM3Yi00ZTkzLTg3OGQtNGIwNWFhNGM2NzEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA5MzY0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBkM2IwN2ExZWNlMTkxMGYyZDFkNDQ4NmM1Njg4NzdlZDhlYjliNWVkNzY2N2NlMjIxMWJlYjExYzQ1ZmY0NGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.wy-Zt0gnUmGhgkBmCkCwdEq5v9tE7TKRCfCWnSU6HXE)
Mobile
![image](https://private-user-images.githubusercontent.com/75388869/287543580-845e22b2-bb80-48e7-862e-ca5845f6af70.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTMzMDAsIm5iZiI6MTczOTM1MzAwMCwicGF0aCI6Ii83NTM4ODg2OS8yODc1NDM1ODAtODQ1ZTIyYjItYmI4MC00OGU3LTg2MmUtY2E1ODQ1ZjZhZjcwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA5MzY0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEwMDI5M2JjZmVmOGIxYjk2N2Y4OWYzYWJhZmQ2YWZlYzIxYTkwMTRkYzQ3N2U0MTg0MzQ1Yjg1MjYzYzFhMDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.pyXkUAd7qASSoVgCa9cZdadzdyVQWKCjZwQL1dvwMjY)
Sanity checks