← Back to Upcase

What if i need an Icebox?


(Anders Lundström) #1

I needed a id_cache_path method a while back (or at least i thought i did)
Now i have to do a little bit of thinking to know why, but i want to keep a note around

I use Trajectory.
Ideas for bigger pictures so i can print a list for a boss
It is now a story, but now the uncertain issues are clogging up
i guess im looking for something like an icebox that pivotal has

Where would you put it or do with it?


(Ben Orenstein) #2

I think @cpytel can help here.


(Chad Pytel) #3

Hi @Rockfordal, What is the action item or task you actually need to do?

This sounds like something you would create a Todo item for and it should be prioritized among everything else you are working on, but a little more info about the actual action you need to take will help confirm that.


(Anders Lundström) #4

The thing is that i actually forgot what action i was going to take. Perhaps i was planning to use it to cache individual records on edit and show.

It makes sense to change it to a TODO, and i think you are right on the spot about prioritizing, i have to take some time and learn how to use trajectory as it was intended. And what the dates on top of issues mean.

In case you want to know what index_cache_path does, it invalidates the etag cache (takes special consideration to countercache and elasticsearch.total_entries, updated_at, params and current_user.role).

 def index
    if stale? upitag
      ...
    end
  end

  def upitag
    icp = index_cache_path
    if icp.present?
      { last_modified: Userprofile.maximum(:updated_at),
        etag: [icp, current_user, flashrand] }
    end
  end

 # def id_cache_path
 # end

  def index_cache_path
    if params[:nc].present?
      false
    else
      icp_string(basecachepath).join('/')
    end
  end

def icp_string(p)
    case ctrlconst.to_s.to_sym
    when :userprofile # Elastic + current_user
      p << Userprofile.search({a: 1}, current_user).total_entries.to_s
    when :orgunit, :urform, :activity, :contact, :mpay, :postal, :zipcode
      p << ctrlconst.search(a: 1).total_entries.to_s
    when :bransch # Countercache
      p << Mainbransch.sum('bransches_count').to_s
    else
      p << ctrlconst.count.to_s
    end
  end

  def ctrlconst
    controller_name.classify.constantize
  end

  def basecachepath
    p = []
    p << ctrlconst.to_s
    p << updated_int
    p << extraparams
    p << current_user.frole
  end

(Chad Pytel) #5

It sounds like index_cache_path is currently unused?

If that is correct - this is what version control is for - if its unused it should be removed and if its important, it can be brought back.


(Anders Lundström) #6

Yes, i have seen Uncle Bob Martins clean code episode about Form, so i know keeping around commented code is a “no-no” :wink:. But now i can start following Bob’s advice and instead just make them a low prioritized “todo” in Trajectory as you suggested in case id want to ponder about implementing them at a later time :smile:. Sorry for a little bit of jibberish. I guess any where for them to live os better than in the code. Or perhaps its like my old clothes hanging in the closet, i need someone to tell me “throw them out, your never gonna use them” :sunny: .


(Chad Pytel) #7

throw them out you’re never going to use them :wink: