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

Display all exemplar files #1908

Merged
merged 7 commits into from Sep 24, 2021
Merged

Display all exemplar files #1908

merged 7 commits into from Sep 24, 2021

Conversation

kntsoriano
Copy link
Contributor

Closes exercism/exercism#5871.

Screenshot

Screen Shot 2021-09-13 at 5 32 25 PM

It probably needs styling.

Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

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

One tiny nit. Nice!

@@ -655,3 +655,8 @@ export type Notification = {
}

type NotificationImageType = 'icon' | 'avatar'

export type GitFile = {
Copy link
Member

Choose a reason for hiding this comment

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

There's not really anything specific to Git for this file. Maybe call this FileWithContents or NamedFile or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah. Good point. For this, I will be very specific and call it MentoringSessionExemplarFile for now. We can then generalize when we have more examples.

@iHiD iHiD closed this Sep 14, 2021
@iHiD iHiD reopened this Sep 14, 2021
@iHiD iHiD closed this Sep 14, 2021
@iHiD iHiD reopened this Sep 14, 2021
@@ -31,7 +31,7 @@ def to_s
anonymous_mode: discussion&.anonymous_mode?
),
mentor_solution: mentor_solution,
exemplar_solution: exercise.exemplar_files.values.first,
exemplar_files: SerializeGitFiles.(exercise.exemplar_files),
Copy link
Member

Choose a reason for hiding this comment

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

@kntsoriano I've inlined the serializing here, as it needs custom rules for this situation (stripping the .meta)

{exemplarFiles.map((file) => {
return (
<div key={file.filename} className="exemplar-files">
{exemplarFiles.length > 1 ? (
Copy link
Member

Choose a reason for hiding this comment

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

@kntsoriano I added this so that the filename only shows if there are multiple. That's broken a couple of tests. Could you get them green pls.

@@ -0,0 +1,23 @@
module ReactComponents
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to add this to serializers/ because it's been getting harder for me to navigate that directory. I think we ought to have some form of object that is local to the react component it is for. I'll have a play with this approach and see where it takes us.

Copy link
Member

Choose a reason for hiding this comment

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

Yep. Serializers should only be used for things that use the API. Other things should be inlined like you've done here.

Copy link
Member

Choose a reason for hiding this comment

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

@kntsoriano I've inlined this into the React component. We don't need extra files for every helper class that's used - we can add things into the one class instead. This is how Rails organises everything internally and it means you don't need to jump around a code base to understand what's going on, which I much prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My reason with breaking this up was to be able to test only what we've changed. It's getting frustrating that when we change one thing here, we need to fix three other tests. I think this is a symptom of not testing things in the right level.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah - totally agree with this too. We should only need to change 1 test if this changes. See #1975

@@ -0,0 +1,25 @@
require_relative "../../../../../app/helpers/react_components/mentoring/session/exemplar_file_list"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm testing without requiring Rails. This will make our test suite faster.

Copy link
Member

@iHiD iHiD Sep 22, 2021

Choose a reason for hiding this comment

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

I'm not sure you actually are. If you don't have Rails then ActiveSupport::TestCase below won't exist so it'll fail. I think you're just not referencing test_helper.rb here, which means if you run this file by itself, it'll be fast, but when you run the whole suite, the test_helper will be required for any file, so the whole thing will render normally.

I might be wrong though and it might be faster, but I can't see why or how it would be.

Copy link
Member

Choose a reason for hiding this comment

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

So changing this back to require test_helper and then running results in this:

Screenshot 2021-09-22 at 16 30 47

So it's already very fast when you just run this as one file. All the slowdown really is when we start to do stuff with databases etc.

Copy link
Member

Choose a reason for hiding this comment

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

@kntsoriano I've reverted this for now. I'm not against doing things like this, but its important we do them systematically across everything rather than just as a one-off variation. So let's work out what we can do to speed everything up and then implement everywhere :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It runs a lot faster without requiring the test helper:
Screen Shot 2021-09-27 at 7 11 52 AM

I know that we want to be systematic about things, but having really slow tests and fixing tests that break when we don't want them really makes it frustrating from day to day.

Copy link
Member

Choose a reason for hiding this comment

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

I know that we want to be systematic about things, but having really slow tests and fixing tests that break when we don't want them really makes it frustrating from day to day.

Totally agree with this. But 0.005s is pretty fast already. Our whole test suite would run in 2s if all the tests were that fast. I don't think this is where the speed improvements are going to come from. There's many tests that take 5s to run, which are 1000x slower than this, which is where I think we need to find solutions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The difference is though is when you TDD and run the tests constantly. This is where the difference lies in getting instant feedback versus waiting another multiple of a second. I find that I get to focus easier and I get work done a lot faster.

I could just then do this setup locally and when I'm going to commit the changes, I'm going to just require test helper.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that makes sense.

@iHiD iHiD merged commit c319e73 into main Sep 24, 2021
@iHiD iHiD deleted the multiple-exemplar-solutions branch September 24, 2021 12:32
iHiD added a commit that referenced this pull request Jul 31, 2023
* Display all exemplar files

* Only show header if there's multiple files

* Fix failing tests

* Rename GitFile to MentoringSessionExemplarFile

* Use test_helper

* Inline exemplar files list

Co-authored-by: Jeremy Walker <jez.walker@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants