OWASP / Maturity-Models

Node application to help managing Maturity Models like the ones created by BSIMM and OpenSAMM
Apache License 2.0
187 stars 51 forks source link

Refactor Data-Project project_Files method #168

Closed DinisCruz closed 8 years ago

DinisCruz commented 8 years ago

in here there is the root cause of "Performance issue on multiple Data_Project methods #167

  project_Files: (id)=>                                        # todo: refactor to make code clear    
    return using (@.projects()[id]),->
      values = []
      if @?.path_Teams          
          for file in @.path_Teams.files_Recursive()          
            if file.file_Extension() in ['.json', '.coffee']
                values.push file
      return values
DinisCruz commented 8 years ago

done

  project_Files: (id)=>
    return cache_project_Files if cache_project_Files         # return cached version if exists
    result = []
    project = @.projects()[id]                               # get list of projects
    if project                                               # if project object exist
      for file in project.path_Teams.files_Recursive()       # find all files recursively (so that folders can be used to organise files)
        if file.file_Extension() in ['.json', '.coffee']     # only support .json and .coffee files
          result.push file
    return (cache_project_Files = result)                    # cache results in cache_project_Files