Skip to content

Commit

Permalink
Use list comprehension on module label list
Browse files Browse the repository at this point in the history
  • Loading branch information
Etiene committed May 5, 2016
1 parent c384ebd commit f7ae6d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
15 changes: 7 additions & 8 deletions applications/modules.moon
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,15 @@ class MoonRocksModules extends lapis.Application
@title = "All modules in #{label.name}"

lmod = LabelsModules\select "where label_id = ?", label.id
query_ids = {0}
for lm in *lmod
table.insert(query_ids,lm.module_id)

query_ids = table.concat(query_ids,",")
if next lmod
query_ids = table.concat [lm.module_id for lm in *lmod], ","
modules = Modules\paginated "where id in (#{query_ids})"

paginated_modules @, (Modules\paginated "where id in (#{query_ids})"), {
per_page: 50
fields: "id, name, display_name, user_id, downloads, summary"
}
paginated_modules @, (modules), {
per_page: 50
fields: "id, name, display_name, user_id, downloads, summary"
}

render: true

Expand Down
11 changes: 7 additions & 4 deletions views/modules_label.moon
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ class Modules extends require "widgets.page"
h2 ->
text @title
text " "
span class: "header_count", "(#{@pager\total_items!})"
span class: "header_count", "(#{@pager and @pager\total_items! or 0})"

@render_pager @pager
@render_modules @modules
@render_pager @pager
if @pager
@render_pager @pager
@render_modules @modules
@render_pager @pager
else
text "No modules"


0 comments on commit f7ae6d7

Please # to comment.