Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy loading ldap user #1104

Merged
merged 14 commits into from Oct 4, 2017
Merged

Lazy loading ldap user #1104

merged 14 commits into from Oct 4, 2017

Conversation

loganfreeman
Copy link
Contributor

@loganfreeman loganfreeman commented Aug 31, 2017

  1. add config entry lazy_load in application.yml ( LAZY_LOAD constant added in 01_obis_setup.rb )

  2. changed directory search to use LAZY_LOAD.

  def self.search(term)
    # Search ldap (if enabled) and the database
    if USE_LDAP && !SUPPRESS_LDAP_FOR_USER_SEARCH
      if LAZY_LOAD
        return self.search_and_merge_ldap_and_database_results(term)
      else
        return self.search_and_merge__and_update_ldap_and_database_results(term)
      end

    else # only search database once
      return search_database(term)
    end
  end

search_and_merge_ldap_and_database_results

just merge the results from database and ldap.

search_and_merge__and_update_ldap_and_database_results

not only merge the results from database and ldap, but also create database record if ldap result not found in database. can create a lot of database record on the fly and be slow

  1. add a method suggestion_value to Identity model
  def suggestion_value
    if LAZY_LOAD && USE_LDAP
      ldap_uid
    else
      id
    end
  end
  1. add a method find_or_create to Identity model
  def self.find_or_create(id)
    if LAZY_LOAD && USE_LDAP
      return Directory.find_or_create(id)
    else
      return self.find(id)
    end
  end
  1. change to use Identity.find_or_create in associated_user_controller new method

shanhong cheng added 2 commits September 1, 2017 15:35
@Stuart-Johnson
Copy link
Collaborator

@Stuart-Johnson Stuart-Johnson merged commit 4872bd9 into sparc-request:v3.0.0b Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants