-
Notifications
You must be signed in to change notification settings - Fork 246
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
Refactor Contributors List to Dynamically Read from File #7374
Refactor Contributors List to Dynamically Read from File #7374
Conversation
Pull Request Test Coverage Report for Build 12737992572Details
💛 - Coveralls |
@hemmatio this approach is correct but you rightly pointed out that reading the file on each request for the about page is inefficient. You can instead read in the contents as a Rails initialization step, storing it in a global variable to be later accessed, similar to what we do for the MarkUs version. |
…er, saving as a global config variable
@@ -0,0 +1,12 @@ | |||
class Contributors | |||
def self.read_contributors |
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.
Make this function return a string rather than a list (since otherwise the same string computation will be repeated every time a user loads the "about" page).
Also use Array#join
to avoid the trailing comma.
Proposed Changes
(Describe your changes here. Also describe the motivation for your changes: what problem do they solve, or how do they improve the application or codebase? If this pull request fixes an open issue, use a keyword to link this pull request to the issue.)
This PR aims to refactor the 'About' section in the dropdown menu located in the top-right corner of MarkUs pages. The contributors list, previously hardcoded in
markus_contributors.html.erb
, is now dynamically read fromdoc/markus-contributors.txt
, which is updated by each new contributor....
Screenshots of your changes (if applicable)
Before:After:
![image](https://private-user-images.githubusercontent.com/129822623/401031409-3e2bc1b1-6434-4566-ac1d-f74d17c1c77f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NzgxMzMsIm5iZiI6MTczODk3NzgzMywicGF0aCI6Ii8xMjk4MjI2MjMvNDAxMDMxNDA5LTNlMmJjMWIxLTY0MzQtNDU2Ni1hYzFkLWY3NGQxN2MxYzc3Zi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOFQwMTIzNTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kYzk5OTk5OTExZGMzNTgxZDg5Y2VlN2RhMzUyZjUxNjU3YzE2NWJlNmYyMDEwNzY0OWI4MDgyMmYxMjM2MjM4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.3ZVzr3lvB9z1Tz5gawblDVZgsAinhOHDHSXXpQaEVs4)
Associated documentation repository pull request (if applicable)
Type of Change
(Write an
X
or a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]
into a[x]
in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)
08/01/25: This should be a decent solution. Maybe it's inefficient to read the file each time it is rendered, and it should be stored in memory instead? Either way, I still have to create test cases. Will likely first test the helper method I created.
08/01/25: Moved file reading step into initializer file (
config/initializers/contributors.rb
), preventing unnecessary repeated computations. TODO: Create test cases12/01/25: Added tests. Waiting for CI results.