whittle down todo file

This commit is contained in:
Devin Howard 2018-01-20 14:47:16 -08:00
parent 8ec5c13a0a
commit df25f84c0f
13 changed files with 27 additions and 66 deletions

View file

@ -13,9 +13,9 @@ AllCops:
Rails:
Enabled: true
#Metrics/LineLength:
# Max: 120
#
Metrics/LineLength:
Max: 120
#Metrics/AbcSize:
# Max: 16

View file

@ -1,12 +1,3 @@
# Offense count: 6
Lint/AmbiguousBlockAssociation:
Exclude:
- 'app/models/event.rb'
- 'app/models/follow.rb'
- 'app/models/mapping.rb'
- 'app/models/synapse.rb'
- 'app/models/topic.rb'
# Offense count: 50
Metrics/AbcSize:
Max: 128
@ -25,12 +16,6 @@ Metrics/ClassLength:
Metrics/CyclomaticComplexity:
Max: 15
# Offense count: 2
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 146
# Offense count: 45
# Configuration parameters: CountComments.
Metrics/MethodLength:
@ -75,24 +60,6 @@ Style/GlobalVars:
- 'app/models/user.rb'
- 'config/initializers/access_codes.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: line_count_dependent, lambda, literal
Style/Lambda:
Exclude:
- 'app/models/follow.rb'
- 'app/models/synapse.rb'
- 'app/models/topic.rb'
# Offense count: 3
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, camelCase
Style/MethodName:
Exclude:
- 'app/models/metacode.rb'
- 'app/models/topic.rb'
# Offense count: 6
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_

View file

@ -17,7 +17,7 @@ module TopicsHelper
rtype: is_map ? 'map' : 'topic',
inmaps: is_map ? [] : t.inmaps(current_user),
inmapsLinks: is_map ? [] : t.inmapsLinks(current_user),
inmapsLinks: is_map ? [] : t.inmaps_links(current_user),
type: is_map ? metamap_metacode.name : t.metacode.name,
typeImageURL: is_map ? metamap_metacode.icon : t.metacode.icon,
mapCount: is_map ? 0 : t.maps.count,

View file

@ -11,7 +11,7 @@ class Event < ApplicationRecord
belongs_to :map
belongs_to :user
scope :chronologically, -> { order('created_at asc') }
scope :chronologically, (-> { order('created_at asc') })
after_create :notify_webhooks!, if: :map

View file

@ -11,9 +11,7 @@ class Follow < ApplicationRecord
after_create :add_subsetting
scope :active, -> {
where(muted: false)
}
scope :active, (-> { where(muted: false) })
private

View file

@ -1,8 +1,8 @@
# frozen_string_literal: true
class Mapping < ApplicationRecord
scope :topicmapping, -> { where(mappable_type: :Topic) }
scope :synapsemapping, -> { where(mappable_type: :Synapse) }
scope :topicmapping, (-> { where(mappable_type: :Topic) })
scope :synapsemapping, (-> { where(mappable_type: :Synapse) })
belongs_to :mappable, polymorphic: true
belongs_to :map, class_name: 'Map', foreign_key: 'map_id', touch: true

View file

@ -6,9 +6,7 @@ class Metacode < ApplicationRecord
has_many :topics
# This method associates the attribute ":aws_icon" with a file attachment
has_attached_file :aws_icon, styles: {
ninetysix: ['96x96#', :png]
},
has_attached_file :aws_icon, styles: { ninetysix: ['96x96#', :png] },
default_url: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png'
# Validate the attached icon is image/jpg, image/png, etc
@ -31,15 +29,13 @@ class Metacode < ApplicationRecord
def as_json(options = {})
default = super(options)
default[:icon] = icon
default.except('aws_icon_file_name', 'aws_icon_content_type', 'aws_icon_file_size', 'aws_icon_updated_at', 'manual_icon')
default.except(
'aws_icon_file_name', 'aws_icon_content_type', 'aws_icon_file_size', 'aws_icon_updated_at',
'manual_icon'
)
end
def hasSelected(user)
return true if user.settings.metacodes.include? id.to_s
false
end
def inMetacodeSet(metacode_set)
def in_metacode_set(metacode_set)
return true if metacode_sets.include? metacode_set
false
end

View file

@ -22,9 +22,9 @@ class Synapse < ApplicationRecord
validates :category, inclusion: { in: ['from-to', 'both'], allow_nil: true }
scope :for_topic, ->(topic_id = nil) {
scope :for_topic, (lambda do |topic_id = nil|
where(topic1_id: topic_id).or(where(topic2_id: topic_id))
}
end)
before_create :set_perm_by_defer
after_create :after_created_async

View file

@ -39,13 +39,13 @@ class Topic < ApplicationRecord
topics1.or(topics2)
end
scope :relatives, ->(topic_id = nil, user = nil) {
scope :relatives, (lambda do |topic_id = nil, user = nil|
# should only see topics through *visible* synapses
# e.g. Topic A (commons) -> synapse (private) -> Topic B (commons) must be filtered out
topic_ids = Pundit.policy_scope(user, Synapse.where(topic1_id: topic_id)).pluck(:topic2_id)
topic_ids += Pundit.policy_scope(user, Synapse.where(topic2_id: topic_id)).pluck(:topic1_id)
where(id: topic_ids.uniq)
}
end)
delegate :name, to: :user, prefix: true
@ -65,13 +65,13 @@ class Topic < ApplicationRecord
Pundit.policy_scope(user, maps).map(&:name)
end
def inmapsLinks(user)
def inmaps_links(user)
Pundit.policy_scope(user, maps).map(&:id)
end
def as_json(options = {})
super(methods: %i[user_name user_image collaborator_ids])
.merge(inmaps: inmaps(options[:user]), inmapsLinks: inmapsLinks(options[:user]),
.merge(inmaps: inmaps(options[:user]), inmapsLinks: inmaps_links(options[:user]),
map_count: map_count(options[:user]), synapse_count: synapse_count(options[:user]))
end

View file

@ -23,7 +23,7 @@ class MapPolicy < ApplicationPolicy
end
def conversation?
show? && %w[connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com ishanshapiro@gmail.com].include?(user.email)
show? && is_tester(user)
end
def create?

View file

@ -35,7 +35,7 @@
<% $i = 0 %>
<% @m = Metacode.order("name").all %>
<% while $i < (Metacode.all.length / 4) do %>
<li id="<%= @m[$i].id %>" <% if not @m[$i].inMetacodeSet(@metacode_set) %>class="toggledOff"<% end %>
<li id="<%= @m[$i].id %>" <% if not @m[$i].in_metacode_set(@metacode_set) %>class="toggledOff"<% end %>
onclick="Metamaps.Admin.liClickHandler.call(this);">
<img src="<%= asset_path @m[$i].icon %>" alt="<%= @m[$i].name %>" />
<p><%= @m[$i].name.downcase %></p>
@ -46,7 +46,7 @@
</ul>
<ul id="filters-two">
<% while $i < (Metacode.all.length / 4 * 2) do %>
<li id="<%= @m[$i].id %>" <% if not @m[$i].inMetacodeSet(@metacode_set) %>class="toggledOff"<% end %>
<li id="<%= @m[$i].id %>" <% if not @m[$i].in_metacode_set(@metacode_set) %>class="toggledOff"<% end %>
onclick="Metamaps.Admin.liClickHandler.call(this);">
<img src="<%= asset_path @m[$i].icon %>" alt="<%= @m[$i].name %>" />
<p><%= @m[$i].name.downcase %></p>
@ -57,7 +57,7 @@
</ul>
<ul id="filters-three">
<% while $i < (Metacode.all.length / 4 * 3) do %>
<li id="<%= @m[$i].id %>" <% if not @m[$i].inMetacodeSet(@metacode_set) %>class="toggledOff"<% end %>
<li id="<%= @m[$i].id %>" <% if not @m[$i].in_metacode_set(@metacode_set) %>class="toggledOff"<% end %>
onclick="Metamaps.Admin.liClickHandler.call(this);">
<img src="<%= asset_path @m[$i].icon %>" alt="<%= @m[$i].name %>" />
<p><%= @m[$i].name.downcase %></p>
@ -68,7 +68,7 @@
</ul>
<ul id="filters-four">
<% while $i < Metacode.all.length do %>
<li id="<%= @m[$i].id %>" <% if not @m[$i].inMetacodeSet(@metacode_set) %>class="toggledOff"<% end %>
<li id="<%= @m[$i].id %>" <% if not @m[$i].in_metacode_set(@metacode_set) %>class="toggledOff"<% end %>
onclick="Metamaps.Admin.liClickHandler.call(this);">
<img src="<%= asset_path @m[$i].icon %>" alt="<%= @m[$i].name %>" />
<p><%= @m[$i].name.downcase %></p>

View file

@ -6,7 +6,7 @@
<script>
<% Metacode.all.each do |m| %>
<% if m.inMetacodeSet(@metacode_set) %>
<% if m.in_metacode_set(@metacode_set) %>
Metamaps.Admin.selectMetacodes.push("<%= m.id %>");
<% end %>
Metamaps.Admin.allMetacodes.push("<%= m.id %>");

View file

@ -6,7 +6,7 @@
<script>
<% Metacode.all.each do |m| %>
<% if m.inMetacodeSet(@metacode_set) %>
<% if m.in_metacode_set(@metacode_set) %>
Metamaps.Admin.selectMetacodes.push("<%= m.id %>");
<% end %>
Metamaps.Admin.allMetacodes.push("<%= m.id %>");