[LRUG] Any words of wisdom please

Mark van Harmelen mark at hedtek.com
Thu Mar 9 05:57:45 PST 2017


Hi all

Pavling, thanks for your comment :)

If anyone else is tempted please, two questions remain, one about future
optimisations of I think three (N+1) queries I used to generate the page at
https://markvan.me/categories/Computer

Am I actually doing three (N+1) queries for starters, and are there words I
can google that might lead me to some improvements, even via caching?

The other on style, I guess, of including a small helper method in a
controller. See below.

Here I'm also not that happy about passing a class around and using it to
control what other methods return. But it seems a consequence of
polymorphism involved in being able to categorise collection items, pages
and resources.

Any advice would be great please, perhaps in this thread?

Thanks
mark

--

github for the full controller
<https://github.com/markvan/social-museum/blob/refactor-bootstrap2/app/controllers/categories_controller.rb>

class CategoriesController < ApplicationController

  def get_categorized(clazz)
      cat = params[:id]
      cat_all = params[:category_id]
      cat ? Category.find_categorized(cat, clazz) :
Category.find_categorized_including_child_categories(cat_all, clazz)
   end

  expose(:categorised_collection_items) { get_categorized(CollectionItem) }
  expose(:categorised_pages)                 { get_categorized(Page) }
  expose(:categorised_resources)           { get_categorized(Resource) }

  # ....



Dr Mark van Harmelen
Director
Hedtek Ltd

+44 7830 212 464

10 Little Lever St, Manchester M1 1HR, UK


On Thu, Mar 9, 2017 at 11:25 AM, Mark van Harmelen <mark at hedtek.com> wrote:

> Hi Lrug
>
> I'm not a profesional rails dev, but I enjoy hacking when I have time.
> I've got a private project on the go, yet another :) wiki [1].
>
> Recently I've done a refactor of some controller and partial code that was
> to me a nice cleanup of something rather horrible.
>
> But I have three residual questions that I put in a gist. My past Rails
> advisor is now terminally busy after a promotion, so I have no advisor to
> ask about these.
>
> If anyone, please, would like to comment on the gist and advise me, I'd be
> a very happy bunny. Or reply in this thread if commenting on a gist is not
> your thing (? surely not anyone here ?).
>
> https://gist.github.com/urbed/de4a1764ca33f8e4bc432c05b1ba3d58
>
> Thanks
> mark
>
> [1] Mediawiki, behind wikipedia, does a fine job for crowdsourcing, why
> write another wiki? An attempt to move from crowdsourcing by editing the
> body of the page, to crowdsourcing by adding comments. i do have a real use
> for this, I know a university with a store room room full of historic
> computer artifacts, and the remaining people who know about them may well
> comment on a wiki page but would never touch a markup language to edit
> page-body text.
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20170309/9cbb4bee/attachment-0002.html>


More information about the Chat mailing list