Scripts are reset but are ScriptLevels?


On Wed, Apr 30, 2014 at 9:15 AM, tobyk100 <notifications@github.com> wrote:

> In app/models/script.rb:
>
> > +      # Concepts are comma-separated, indexed by name
> > +      row['concept_ids'] = (concepts = row.delete('concepts')) && concepts.split(',').map(&:strip).map do |concept_name|
> > +        (Concept.find_by_name(concept_name) || raise("missing concept '#{concept_name}'")).id
> > +      end
> > +
> > +      # Reference one Level per element
> > +      level = custom ?
> > +        Level.find_by(name: row['name']) :
> > +        Level.where(game: Game.find_by(name: row.delete('game')), level_num: row['level_num']).first_or_create
> > +
> > +      raise "There does not exist a level with the name '#{row['name']}'. From the row: #{row}" if level.nil?
> > +      raise "Level #{level.to_json}, does not have a game." if level.game.nil?
> > +      stage = row.delete('stage')
> > +      level.update(row)
> > +
> > +      script_level = ScriptLevel.where(
>
> There's an implicit assumption that scripts are only created once, in this
> task. Since they are reset
> https://github.com/code-dot-org/dashboard/pull/538/files#diff-9cacd63540753d6929377d6cb58210cbR77there's no chance of duplicate chapters. However, it may be good to
> document that either with a comment how with code.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/code-dot-org/dashboard/pull/538/files#r12151550>
> .
>