i dealing with this code, but i always getting more than 10 seconds to
load, i even upgraded the server, but is the same.... i know i have some
database design problem, but i cant modify that.

i am showing all the prices from differents locations of products of a
category also in different time range, because the prices change every
15 days in each location.

# controller

def prods_x_cat
# This will load all the products of a category
@products = Product.prods_x_cat(params[:id],:include =>
:raw_datas)
@cortes = RawData.cortes
respond_to do |format|
format.js { render :layout=>false}
end
end



# prods_x_cat.js.erb


var jqxhr1 = $.ajax($("#loading_overlay .loading_message,
#loading_overlay").fadeIn());
$('#datos').html("<%= escape_javascript render
:partial=>'/shared/prods_x_cat'%>")


# view

<%@cortes.each do |c|%>
<a href="#<%=c.corte%>" class="round_top"><%=c.corte%></a>
<%end%>
<%@cortes.each do |c|%>
<%@fecha = c.corte_real%>
<div id="<%=c.corte%>" class="block no_padding">
<table class="display datatable">
<thead>
<tr>
<th>SKU</th>
<%Company.active.order('table_field ASC').each do |c|%>
<th><%=c.abbr%></th>
<%end%>
<th>Average</th>
<th>Mode</th>
<th>Minimum</th>
<th>Maximum</th>
</tr>
</thead>
<tbody>
<%@products.each do |p|%>
<tr class="gradeA">
<td><%=p.name%></td>
<%p.raw_datas.where("product_id='#{p.id}' and
corte_real='#{@fecha}'").each do |prd|%>
<td><%=prd.location1.to_f.round(2)%></td>
<td><%=prd.location2.to_f.round(2)%></td>
<td><%=prd.location3.to_f.round(2)%></td>
<td><%=prd.location4.to_f.round(2)%></td>
<td><%=prd.location5.to_f.round(2)%></td>
<td><%=prd.location6.to_f.round(2)%></td>
<td><%=prd.location7.to_f.round(2)%></td>
<td><%=prd.location8.to_f.round(2)%></td>
<td><%=prd.promedio.to_f.round(2)%></td>
<td><%=prd.moda%></td>
<td><%=prd.minimo.to_f.round(2)%></td>
<td><%=prd.maximo.to_f.round(2)%></td>
<%end%>
</tr>
<%end%>
</tbody>
</table>
</div>
<%end%>
</div>



i know it should be something with the query, still don't know

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Johann Aman at Nov 5, 2011 at 11:11 am
    1. are you sure all foreign keys are indexed
    2. could you also post table structures and queries generated, it
    might help to understand the problem
    On Nov 4, 11:35 pm, Edgar Gonzalez wrote:
    i dealing with this code, but i always getting more than 10 seconds to
    load, i even upgraded the server, but is the same.... i know i have some
    database design problem, but i cant modify that.

    i am showing all the prices from differents locations of products of a
    category also in different time range, because the prices change every
    15 days in each location.

    # controller

    def prods_x_cat
    # This will load all the products of a category
    @products =  Product.prods_x_cat(params[:id],:include =>
    :raw_datas)
    @cortes = RawData.cortes
    respond_to do |format|
    format.js { render :layout=>false}
    end
    end

    # prods_x_cat.js.erb

    var jqxhr1 = $.ajax($("#loading_overlay .loading_message,
    #loading_overlay").fadeIn());
    $('#datos').html("<%= escape_javascript render
    :partial=>'/shared/prods_x_cat'%>")

    # view

    <%[email protected] do |c|%>
    <a href="#<%=c.corte%>" class="round_top"><%=c.corte%></a>
    <%end%>
    <%[email protected] do |c|%>
    <%@fecha = c.corte_real%>
    <div id="<%=c.corte%>" class="block no_padding">
    <table class="display datatable">
    <thead>
    <tr>
    <th>SKU</th>
    <%Company.active.order('table_field ASC').each do |c|%>
    <th><%=c.abbr%></th>
    <%end%>
    <th>Average</th>
    <th>Mode</th>
    <th>Minimum</th>
    <th>Maximum</th>
    </tr>
    </thead>
    <tbody>
    <%[email protected] do |p|%>
    <tr class="gradeA">
    <td><%=p.name%></td>
    <%p.raw_datas.where("product_id='#{p.id}' and
    corte_real='#{@fecha}'").each do |prd|%>
    <td><%=prd.location1.to_f.round(2)%></td>
    <td><%=prd.location2.to_f.round(2)%></td>
    <td><%=prd.location3.to_f.round(2)%></td>
    <td><%=prd.location4.to_f.round(2)%></td>
    <td><%=prd.location5.to_f.round(2)%></td>
    <td><%=prd.location6.to_f.round(2)%></td>
    <td><%=prd.location7.to_f.round(2)%></td>
    <td><%=prd.location8.to_f.round(2)%></td>
    <td><%=prd.promedio.to_f.round(2)%></td>
    <td><%=prd.moda%></td>
    <td><%=prd.minimo.to_f.round(2)%></td>
    <td><%=prd.maximo.to_f.round(2)%></td>
    <%end%>
    </tr>
    <%end%>
    </tbody>
    </table>
    </div>
    <%end%>
    </div>

    i know it should be something with the query, still don't know

    --
    Posted viahttp://www.ruby-forum.com/.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to [email protected].
    To unsubscribe from this group, send email to [email protected].
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 4, '11 at 7:35p
activeNov 5, '11 at 11:11a
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Johann Aman: 1 post Edgar Gonzalez: 1 post

People

Translate

site design / logo © 2023 Grokbase