Note that there are some explanatory texts on larger screens.

plurals
  1. POI've created a disaster. Please point out a coding strategy to refactor this
    primarykey
    data
    text
    <p><strong>UPDATE</strong></p> <p>So far I've cut it down significantly:</p> <pre><code> # Gets the user's Wall # I used object methods so they can be called by other methods, such as #second_wall() def read_wall(fbuserid) @result ||= graph.get_connections(fbuserid, 'feed') end def second_wall(fbuserid) @second ||= @result.next_page end def third_wall(fbuserid) @third ||= @second.next_page end def fourth_wall(fbuserid) fourth ||= @third.next_page end # Collects your friends' wall Posts and puts the IDs into an array # the number array contains method names that will be called # This is done to read 100 wall posts def get_post_ids(fbuserid) var = [] number = [read_wall(fbuserid), second_wall(fbuserid), third_wall(fbuserid), fourth_wall(fbuserid)] number.each do |iterate| num ||= iterate for i in 0..25 if find_nil(num, [i,'id']).nil? == false var &lt;&lt; num[i]['id'] end end end </code></pre> <p>Originally, I had everything in the base method #read_wall(). I'm not sure what happened with the array, but when I tried:</p> <p><code>array = result + second + third + fourth</code>. I was left with data from only the original result. So I created this working disaster. <strong>Can you please help me refactor this?</strong></p> <pre><code> # Gets the user's Wall def read_wall(fbuserid) result ||= graph.get_connections(fbuserid, 'feed') end def second_wall(fbuserid) result ||= graph.get_connections(fbuserid, 'feed') second ||= result.next_page end def third_wall(fbuserid) result ||= graph.get_connections(fbuserid, 'feed') second ||= result.next_page third ||= second.next_page end def fourth_wall(fbuserid) result ||= graph.get_connections(fbuserid, 'feed') second ||= result.next_page third ||= second.next_page fourth ||= third.next_page end # Collects your friends' wall Posts and puts the IDs into an array def get_post_ids(fbuserid) x ||= read_wall(fbuserid) var = [] for i in 0..25 if find_nil(x, [i,'id']).nil? == false var &lt;&lt; x[i]['id'] end end second_wall ||= second_wall(fbuserid) for i in 0..25 if find_nil(second_wall, [i,'id']).nil? == false var &lt;&lt; second_wall[i]['id'] end end third_wall ||= third_wall(fbuserid) for i in 0..25 if find_nil(third_wall, [i,'id']).nil? == false var &lt;&lt; third_wall[i]['id'] end end fourth_wall ||= fourth_wall(fbuserid) for i in 0..25 if find_nil(fourth_wall, [i,'id']).nil? == false var &lt;&lt; fourth_wall[i]['id'] end end @get_post_ids = var end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload