-
Notifications
You must be signed in to change notification settings - Fork 138
#1742 fix progress calendar #1803
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
base: develop
Are you sure you want to change the base?
Conversation
| $dayOfWeek = $startDate->dayOfWeekIso; | ||
| $emptySquaresCount = $dayOfWeek - 1; | ||
|
|
||
| for ($i = 0; $i < $emptySquaresCount; $i += 1) { |
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.
тк squares это коллекция, то можно создать новую коллекцию с пустыми элементами и смержить их (одну к другой подсоединить), вместо цикла.
| $currentMonth = now()->month; | ||
| $startDate = now()->subYear(); | ||
| $endDate = now(); | ||
| $currentDate = $startDate->copy()->startOfWeek(); |
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.
написано currentDate, а метод возвращает начало недели
| $currentMonth = null; | ||
| $weekCount = 0; | ||
|
|
||
| while ($currentDate->lte($endDate)) { |
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.
По возможности стоит избегать while цикла - читается тяжко, тяжко дебажить и так далее.
Если внутри мы что-то выполняем, то тут можно спокойно использовать приватный метод. Тк ниже еще два вложенных условия и сходу не онять алгоритм того, а что там происходит. тут мы или комментариями можем пояснить. можно в ПРе тут ответить и подумаем кк лучше.
Представь что ты этот код будешь читать через полгода - сможешь ли понять, что тут происходит?)
| if ($currentMonth !== null) { | ||
| $months[] = [ | ||
| 'month' => Month::fromNumber($currentMonth), | ||
| 'weeks' => $weekCount, |
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.
weeks - множ число используем для коллекций, а тут видимо int.
Плюс если у тут опять же можно использовать класс, чтобы создать простую обертку над ассоц массивом - так туда ничего лишнего не запишут + редактор убедт подсказывать.
| flex: 0 0 auto; | ||
| } | ||
|
|
||
| @for $weeks from 1 through 6 { |
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.
не знаю, может потом порешается, то codacy ругнулся на это Unexpected unknown at-rule "@for" (at-rule-no-unknown), хз наскок критично), думаю можно потом погуглитькак пофиксить.
Поправил баг календаря со смещенными днями недели + поменял локаль в профиле (Разделы на Главы)
посмотреть можно тут https://hexlet-sicp-aakz.onrender.com