Initial Setup

The prefered and supported way to maintain a replicable development environment is with Docker. Download Docker from their website: https://www.docker.com/products/docker-desktop/ . No subscription is required, just choose the free-est options. You can, of course, setup your own environment without Docker, but this is not covered in this documentation.

Once installed, simply run the following commands from the root source code folder to get started:

docker-compose build
docker-compose up

Next, you will need a .env file that contains some application secrets. For security reasons this is not part of the repo, but can be obtained by contacting the developers for appropriate uses.

The first time docker-compose up is run, your database will be initialized with a single admin: vp@sjaa.net. To generate more sample data, run the following rake task. Make sure your docker containers are running.

docker container exec -it sjaa-memberships-app-1 bin/rake generate_data

Now, you should be able to navigate to https://127.0.0.1:3001 to view your local copy of the application, complete with sample data. You may get a warning from your browser that the connection is not secure. This is because we use a self-signed certificate in development. It is safe to click through those warnings to access the app.

Console

docker container exec -it sjaa-memberships-app-1 bin/rails c 

Use Cases

The app should serve as a secure store for the membership data, and should facilitate a variety of use cases:

  1. Lookup a person’s membership status
    # By name
    Person.find_by(last_name: 'Nomo').status.name
    => "member"
    
    # By email
    Person.joins(:contacts).where(contact: {email: 'nomo@gmail.com'}).first.status.name
    => "member"
    
  2. Get a person’s contact information
    Person.find_by(last_name: 'Nomo').contacts
    => 
    [#<Contact:0x0000ffff80a67220
      id: 126,
      address: "123 Fake St",
      city_id: 5,
      state_id: 1,
      zipcode: "95555",
      phone: "123-456-7890",
      email: "jorge.conseco@att.net",
      primary: true,
      person_id: 126]
    
  3. Lookup the donation history for any given member
    Person.find_by(id: 42).donations
    
  4. Lookup a person’s membership renewal history
    Person.find_by(id: 42).memberships
    
  5. Lookup when a person first joined
    Person.find_by(id: 42).memberships.order(start: :asc).first.start
    => Sat, 21 Sep 2019 00:00:00.000000000 UTC +00:00
    
  6. Lookup when a person’s membership expires
    membership = Person.find_by(id: 42).memberships.order(start: :desc).first
    expiration = membership.start + membership.term_months.months
    => Mon, 24 Nov 2025 00:00:00.000000000 UTC +00:00
    
  7. Find members whose memberships have lapsed
    # All expired memberships
    Person.lapsed_members
    
    # Expired memberships who still have the "member" standing
    Person.lapsed_members(status: 'member')