Skip to content

Commit

Permalink
Merge pull request #673 from pil0u/main
Browse files Browse the repository at this point in the history
Release 2024.11.2
  • Loading branch information
pil0u authored Nov 14, 2024
2 parents ec5ff2f + f5aec4b commit d49b758
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .erb-lint.yml → .erb_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ linters:
HardCodedString:
exclude:
- "**/app/components/**/*"
- "**/app/components/*" # https://github.com/Shopify/erb-lint/issues/265
- "**/app/components/*" # https://github.com/Shopify/erb_lint/issues/265
- "**/app/views/**/*"

Rubocop:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
- name: Run RuboCop
run: bundle exec rubocop

erb-lint:
erb_lint:
# ERB & HTML static code analyzer and formatter
# https://github.com/Shopify/erb-lint
# https://github.com/Shopify/erb_lint

name: ERB Lint
runs-on: ubuntu-latest
Expand All @@ -40,7 +40,7 @@ jobs:
bundler-cache: true

- name: Run ERB Lint
run: bundle exec erblint --lint-all --enable-all-linters
run: bundle exec erb_lint --lint-all --enable-all-linters

rspec:
name: RSpec
Expand Down
6 changes: 6 additions & 0 deletions app/assets/images/icons/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions app/components/footer/authors_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"https://www.lewagon.com",
target: :_blank,
rel: :noopener,
class: "link-explicit decoration-wagon-red" %>
class: "link-explicit hover:text-wagon-red" %>
&
<%= link_to "ShipOnRails",
"https://shiponrails.com",
target: :_blank,
rel: :noopener,
class: "link-explicit decoration-aoc-green" %>
class: "link-explicit hover:text-aoc-green" %>
| Made with ♥️ by
<%= link_to "pil0u",
"https://lewagon-alumni.slack.com/team/URZ0F4TEF",
Expand Down
14 changes: 14 additions & 0 deletions app/components/users/account_settings_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@
) do %>
Link Slack account
<% end %>
<div data-controller="clipboard"
data-clipboard-content-value="lewagon-alumni"
class="relative group">
<%= inline_svg_tag "icons/info.svg",
data: { action: "click->clipboard#copy" },
class: "w-5 h-5 inline-block hover:opacity-90 active:opacity-70 cursor-pointer" %>
<span class="hidden absolute w-max top-2 left-6 text-xs group-hover:block">
Click to copy the workspace URL
</span>
<span data-clipboard-target="feedback"
class="hidden absolute w-max top-6 left-6 text-xs">
Copied! → lewagon-alumni.slack.com
</span>
</div>
</div>

<% end %>
Expand Down
24 changes: 21 additions & 3 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,25 @@ def code_of_conduct
@admins = User.admins.pluck(:username)
end

def faq; end
def faq
@insanity_points = [
["alpha", 1, 1, "1 minute", 5],
["bravo", 1, 1, "1 minute 1 second", 4],
["charlie", 1, 1, "1 hour", 3],
["delta", 1, 1, "2 hours", 2],
["echo", 1, 1, "5 days", 1],
["foxtrot", 1, 1, "5 days 2 hours", 0],
["alpha", 1, 2, "never", 0],
["bravo", 1, 2, "6 hours", 4],
["charlie", 1, 2, "6 days", 2],
["delta", 1, 2, "3 hours", 5],
["echo", 1, 2, "5 days 2 hours", 3],
["foxtrot", 1, 2, "6 days 1 minute", 1]
]
@insanity_scores = @insanity_points.group_by { |row| row[0] }
.transform_values { |rows| rows.sum { |row| row[4] } }
.sort_by { |_, score| -score }
end

def participation
users_per_city = City.joins(:users).group(:id).count
Expand Down Expand Up @@ -62,7 +80,7 @@ def setup
@sync_status = if current_user.aoc_id.nil? || !current_user.accepted_coc
{ status: "KO", css_class: "text-wagon-red" }
else
{ status: "Pending", css_class: "text-aoc-atmospheric" }
{ status: "Pending", css_class: "text-aoc-bronze" }
end

return if cookies[:referral_code].blank?
Expand Down Expand Up @@ -92,7 +110,7 @@ def stats
end
@users_per_star = (@daily_completers.map { |h| h[:gold_completers] + h[:silver_completers] }.max.to_f / 50).ceil

@current_user_solved_today = current_user.completions.where(day: Aoc.latest_day).count
@current_user_solved_today = current_user.completions.where(day: Aoc.latest_day).count if current_user.present?
end

def welcome
Expand Down
93 changes: 57 additions & 36 deletions app/views/pages/faq.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,22 @@

<div class="flex flex-col gap-y-2 text-justify">
<p>
Puzzle difficulty varies throughout the event. The first part of each puzzle is
<span class="strong">generally accessible to all Wagoners, students and Alumni</span>. The second part is
more challenging but still doable for various experience levels.
Puzzle difficulty varies throughout the event.
</p>
<p>
Puzzle difficulty <span class="strong">does not strictly increase</span> during the event. You might find puzzle
#21 easier than #6, depending on your skills, experience, or the puzzle creator's design.
The first part of most puzzles, especially in the first half of the event, is
<span class="strong">usually accessible to most Wagoners, students and Alumni</span>. The second part is more
challenging.
</p>
<p>
<span class="strong">Never give up.</span>
Puzzle difficulty <span class="strong">roughly increases</span> during the event. That said, you might find
puzzle #21 easier than #6, depending on your skills, experience, or the puzzle creator's design.
</p>
<p class="text-center text-gold">
Never give up.
</p>
<p>
Take a shot at every puzzle. You never know what you can achieve until you try.
</p>
<p>
If you are stuck, open a discussion <%= link_to "on Slack",
Expand Down Expand Up @@ -193,7 +199,7 @@
</details>

<details>
<%= render Faq::DetailsSummaryComponent.new(title: "The Ladder of Insanity?!") %>
<%= render Faq::DetailsSummaryComponent.new(title: "How does the scoring system work?") %>

<div class="flex flex-col gap-y-2 text-justify">
<p>
Expand All @@ -217,53 +223,68 @@

<p>
For each <em>part</em>, participants are ranked by relative solving time:
<ul class="ml-7 list-disc list-inside">
<li>1st place: <code class="strong">5</code> points</li>
<li>2nd place: <code class="strong">4</code> points</li>
<li>3rd place: <code class="strong">3</code> points</li>
<li>4th place: <code class="strong">2</code> points</li>
<li>5th place: <code class="strong">1</code> point</li>
<li>6th place and beyond: <code class="strong">0</code> points</li>
</ul>
</p>

<p>Example:</p>
<ul class="ml-7 list-disc list-inside">
<li>1st place: <code class="strong">5</code> points</li>
<li>2nd place: <code class="strong">4</code> points</li>
<li>3rd place: <code class="strong">3</code> points</li>
<li>4th place: <code class="strong">2</code> points</li>
<li>5th place: <code class="strong">1</code> point</li>
<li>6th place and beyond: <code class="strong">0</code> points</li>
</ul>

<p>
Suppose day 1 is over with the following results:
</p>

<table class="mx-auto w-96 border border-aoc-gray-dark">
<thead class="text-center border-b border-aoc-gray-dark">
<tr>
<th>Username</th>
<th>Total Score</th>
</tr>
</thead>
<tbody class="text-center text-xl">
<% @insanity_scores.each do |username, total_score| %>
<tr>
<td class="text-sm"><%= username %></td>
<td class="strong"><%= total_score %></td>
</tr>
<% end %>
</tbody>
</table>

<table class="w-full text-center">
<thead>
<p>This is how the individual completions might look like:</p>
<table class="mx-auto w-96 border border-aoc-gray-dark">
<thead class="text-center border-b border-aoc-gray-dark">
<tr>
<th>Username</th>
<th>Day</th>
<th>Part</th>
<th>Time to complete</th>
<th>Score</th>
</tr>
</thead>
<tbody class="text-center text-xl">
<% [
["alpha", 1, 1, "1 minute", 5],
["bravo", 1, 1, "1 minute 1 second", 4],
["charlie", 1, 1, "1 hour", 3],
["delta", 1, 1, "2 hours", 2],
["echo", 1, 1, "5 days", 1],
["foxtrot", 1, 1, "5 days 2 hours", 0],
["alpha", 1, 2, "never", 0],
["bravo", 1, 2, "6 hours", 4],
["charlie", 1, 2, "6 days", 2],
["delta", 1, 2, "3 hours", 5],
["echo", 1, 2, "5 days 2 hours", 3],
["foxtrot", 1, 2, "6 days 1 minute", 1]
].each do |username, day, challenge, time, score| %>
<tr>
<% @insanity_points.each_with_index do |(username, day, challenge, time, score), index| %>
<tr class="<%= "border-b border-dashed" if index == 5 %>">
<td class="text-sm"><%= username %></td>
<td><%= day %></td>
<td><%= challenge %></td>
<td class="text-sm"><%= time %></td>
<td class="strong"><%= score %></td>
</tr>
<% end %>
</tbody>
</table>

<p>
In case of a tie, participants are ranked following these criteria:
<ol class="ml-7 list-decimal list-inside">
<li>Total number of stars (the more, the better)</li>
<li>Total solving time (the less, the better)</li>
<li>User ID (the earlier you signed up, the better)</li>
</ol>
</p>
</div>
</details>

Expand Down Expand Up @@ -296,7 +317,7 @@
<div class="flex flex-col gap-y-2 text-justify">
<p>
The last puzzle is released on December 25th, but the solving deadline is
<span class="strong"><%= "#{Aoc.lewagon_end_time.to_fs(:long_ordinal)} #{Aoc.lewagon_end_time.zone}" %></span>.
<span class="strong"><%= "#{Aoc.lewagon_end_time.to_fs(:long_ordinal)}am #{Aoc.lewagon_end_time.zone}" %></span>.
After this, all scores freeze, and results will be announced.
</p>
</div>
Expand Down
57 changes: 36 additions & 21 deletions app/views/pages/setup.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<% end %>
</div>
</li>

<li>
<%= link_to(
"Log in to Advent of Code",
Expand All @@ -37,6 +38,7 @@
class: "link-explicit link-external"
) %> (e.g. using your GitHub account).
</li>

<li>
<div>
<p>
Expand All @@ -54,6 +56,7 @@
</p>
</div>
</li>

<li>
<%= link_to(
"Go to your settings",
Expand All @@ -63,6 +66,7 @@
class: "link-explicit link-external"
) %> and get the number next to <code>anonymous user #<span class="strong">XXXXXXX</span></code> (your ID)
</li>

<li>
<div class="flex flex-col gap-y-2">
<p>
Expand Down Expand Up @@ -104,33 +108,44 @@

<p>
After saving, your sync status at the top of this page should change to
<span class="text-aoc-atmospheric">Pending</span>.
<span class="text-aoc-bronze">Pending</span>.
</p>
</div>
</li>
<li>
<div class="flex flex-col gap-y-2">
<p>
Configure your personal settings:
</p>
<%= render Users::AccountSettingsComponent.new(user: current_user) %>
</div>
</li>

<li>
Read the <%= link_to "FAQ", faq_path, class: "link-explicit link-internal" %>
</li>

<% if current_user.aoc_id.present? %>
<hr class="my-4 border-aoc-gray-darker">

<li>
<div class="flex flex-col gap-y-2">
<p>
Configure your personal settings:
</p>
<%= render Users::AccountSettingsComponent.new(user: current_user) %>
</div>
</li>
<% end %>
</ol>
</div>

<p>
Congratulations, your setup is now complete! Every 10 minutes, our platform syncs with adventofcode.com API. Soon,
this page will vanish, replaced by your personal advent calendar ✨
</p>

<p class="mt-4 italic text-sm opacity-80">
If you have completed all these steps, <b>waited at least 10 minutes</b>, and your status is still
<span class="not-italic text-aoc-atmospheric">Pending</span>, please send a message in this
<%= link_to "Slack thread", "https://lewagon-alumni.slack.com/archives/C02PN711H09/p1700598449505399", target: :_blank, rel: :noopener, class: "link-explicit link-slack" %>
with the following details:
<code class="not-italic strong">id:<%= current_user.id %>;aoc_id:<%= current_user.aoc_id %></code>
</p>
<% if current_user.aoc_id.present? %>
<p>
Congratulations, your setup is now complete!
</p>
<p>
In the next 10 minutes, our platform will sync with adventofcode.com API
in the background. You can then refresh this page, it will be replaced by your personal advent calendar ✨
</p>

<p class="mt-4 italic text-sm opacity-80">
If you have completed all these steps, <b>waited at least 10 minutes</b>, and your status is still
<span class="not-italic text-aoc-bronze">Pending</span>, please send a message in this
<%= link_to "Slack thread", "https://lewagon-alumni.slack.com/archives/C02PN711H09/p1700598449505399", target: :_blank, rel: :noopener, class: "link-explicit link-slack" %>
with the following details:
<code class="not-italic strong">id:<%= current_user.id %>;aoc_id:<%= current_user.aoc_id %></code>
</p>
<% end %>
4 changes: 2 additions & 2 deletions app/views/scores/insanity.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<%= render PageTitleComponent.new(title: "The Ladder of Insanity") %>

<p class="my-4">
The first 5 players to solve a part of a puzzle get respectively 5, 4, 3, 2 and 1 point.
<%= link_to "More info", faq_path, class: "link-explicit link-internal" %>.
The first 5 players to solve a part of a puzzle get respectively 5, 4, 3, 2 and 1 point. In case of a tie, players are
ranked by their total number of stars. <%= link_to "More info", faq_path, class: "link-explicit link-internal" %>.
</p>

<table class="block overflow-x-auto whitespace-nowrap w-full max-w-2xl mx-auto">
Expand Down

0 comments on commit d49b758

Please sign in to comment.