 (defn rs->price-event
   [price-event-rs]
   (-> price-event-rs
+      (ucore/replace-if-contains :fs_id        :price-event/fs-id)
       (ucore/replace-if-contains :type_id      :price-event/fs-type-id)
       (ucore/replace-if-contains :street       :price-event/fs-street)
       (ucore/replace-if-contains :city         :price-event/fs-city)

                 " and f.deleted_at is null and fs.deleted_at is null"
                 (format " order by %s" sort-by-clause)
                 (format " limit %s" max-results))
        args (if (not (nil? event-date-after)) [(c/to-timestamp event-date-after)] [])]
    (j/query db-spec
             (vec (concat [qry] args))
             :row-fn rs->price-event)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Fuel purchase log-related definitions.

   distance-within
   event-date-after
   sort-by
   max-results
   min-distance-diff-fs]
  (let [sort-by-clause (reduce (fn [clause [col dir]] (format "%s%s %s," clause col dir)) "" sort-by)
        sort-by-clause (.substring sort-by-clause 0 (dec (count sort-by-clause)))
        qry (str "select fs.id as fs_id, fs.type_id, f.gallon_price, f.octane, f.is_diesel, "
                 "f.purchased_at, fs.latitude, fs.longitude, fs.street, fs.city, fs.state, fs.zip, "
                 (format "ST_Distance(fs.location, ST_Geomfromtext('POINT(%s %s)', 4326)::geography) as distance" longitude latitude)
                 (format " from %s f, %s fs" fpddl/tbl-fplog fpddl/tbl-fuelstation)
