estately / rets

A pure-ruby library for fetching data from RETS servers
https://github.com/estately/rets
127 stars 94 forks source link

lookup tables case insensitively #163

Closed BlakeJenningsJohnson closed 9 years ago

BlakeJenningsJohnson commented 9 years ago

Whilst adding solds for one MLS we noticed the data coming back didn't match the case of the same fields in the metadata.

The only way this could be a problem is if an mls has two tables with different casing which seems very unlikely.

hfaulds commented 9 years ago

I used a script to search through all of our metadata to find if this would cause any problems. The only MLS I found with duplicate table names whilst case insensitive was WARDEX:

    Table: TotalUnits
      Resource: Property
      ShortName: Total Units
      LongName: Total Units
      StandardName: 
      Units: 
      Searchable: true
      Required: 
    LookupTable: TotalUnits
      Resource: Property
      Required: 
      Searchable: true
      Units: 
      ShortName: Total # Units
      LongName: Units
      StandardName: 
      Types:
        Above Ground -> abv
        Community -> com
        Ground Set -> grn
        No -> no
        Private -> prv

This isn't a new problem, both tables have the same casing.

At a glance this is likely a mistake in their metadata or our parsing of their metadata (given the values for the LookupTable make no sense).

So as far as I can tell this PR is as safe as the existing code.

hfaulds commented 9 years ago

The jist of the script I ran:

mlses.select { |mls|
  client = #Create a rets client for the mls
  client.metadata.tree.values.any? { |r|
    r.rets_classes.any? { |c|
      table_names = c.tables.flat_map { |t| t.name.downcase }
      table_names.size != table_names.uniq.size
    }
  }
}.map(&:acronym)

(I remove estatley-specific code and I actually rescued some exceptions and reran for those mlses that error'd first time round)

tdtran commented 9 years ago

Looks good. Thanks for taking the extra time to verify the PR against real data.