[openstreetmap/openstreetmap-website] Microcosms microcosms (PR #3683)

Brian DeRocher notifications at github.com
Sat Sep 17 20:03:28 UTC 2022


@openbrian commented on this pull request.



> +  before_action :set_microcosm, :only => [:edit, :show, :update]
+
+  helper_method :recent_changesets
+
+  load_and_authorize_resource :except => [:create, :new]
+  authorize_resource
+
+  def index
+    # TODO: OMG is the math right here?
+    minute_of_day = "(60 * EXTRACT(HOUR FROM current_timestamp) + EXTRACT(MINUTE FROM current_timestamp))"
+    morning = "(60 * 6)" # 6 AM
+    long_facing_sun = "(#{minute_of_day} + #{morning}) / 4"
+    # Using Arel.sql here because we're using known-safe values.
+    @microcosms = Microcosm.order(Arel.sql("longitude + 180 + #{long_facing_sun} DESC"))
+
+    @microcosms_i_organize = current_user ? current_user.microcosms_i_organize : []

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3683#discussion_r973623016
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/3683/review/1111466403 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20220917/5d610be7/attachment.htm>


More information about the rails-dev mailing list