Specifically NewYearsResolutionBadge
.
Published the solution here: SleeplessByte's solution for Regular Chatbot in JavaScript on Exercism. Should be January first in my timezone ánd UTC.
Specifically NewYearsResolutionBadge
.
Published the solution here: SleeplessByte's solution for Regular Chatbot in JavaScript on Exercism. Should be January first in my timezone ánd UTC.
I’m so glad this question has been asked !
I actually wanted to ask about this, but didn’t want to give the impression I could be a badge junkie
There’s a badge just for publishing a solution today? Good to know, but of course I would have solved an exercise right before going to bed anyway. Totally. For sure.
I got the badge seconds after opening the online editor. I did that for like 22 hours ago or something.
I submitted a solution about 10AM my local time (UTC +10 Daylight Saving). I would say the submission time is currently determined based on the local time of the server(s) location ? If so, my submission may have been a little early.
I hope adjustments can be made to compensate for this difference. Cause I’d really like my badge !
It’s currently using this code: website/app/models/badges/new_years_resolution_badge.rb at main · exercism/website · GitHub
def self.worth_queuing?(solution:)
solution.created_at.yday == 1
end
def award_to?(user)
user.solutions.
where('DAYOFYEAR(solutions.created_at) = 1').
exists?
end
The first check uses the ruby / rails timezone (Time.zone
). The second one uses the (My)SQL DAYOFYEAR
function. By default, rails will store created_at
as UTC. As long as the time zone is actually set as UTC, the two functions will both result in true at the same time.
This would mean that UTC+10 at > 10:00 would work and < 10:00 would not.
@ErikSchierboom can you check this?
Sure. The rails time zone is UTC:
Time.zone
=> #<ActiveSupport::TimeZone:0x00007f89a66c2a28 @name="UTC", @tzinfo=#<TZInfo::DataTimezone: Etc/UTC>, @utc_offset=nil>
MySQL is set to the system time:
mysql> SELECT @@global.time_zone, @@session.time_zone;
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM | SYSTEM |
+--------------------+---------------------+
1 row in set (0.00 sec)
mysql> select timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00'));
+----------------------------------------------------------------+
| timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00')) |
+----------------------------------------------------------------+
| 00:00:00 |
+----------------------------------------------------------------+
1 row in set (0.00 sec)
Great. That seems right.
I still don’t have the badge
Can you link me to your solution?
It’s in the top post.
Ah sorry, missed that. I’ll check it out
Found a bug in the code: Award new years resolution badge when iteration is created, not solution by ErikSchierboom · Pull Request #3364 · exercism/website · GitHub
It’s there!
(…Filler text to hit minimum post character limit…)
Sorry to trouble you, @ErikSchierboom, but could my NewYearsResolutionBadge issue also be looked into. ?
Submitted morning of 20230101, my local time (UTC+10 DS).
ajborla’s Difference of Squares Solution
Thank you.
Done. Should be there now.
Thank you !