Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jazzido/mondrian-rest
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.0
Choose a base ref
...
head repository: jazzido/mondrian-rest
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: public
Choose a head ref
  • 14 commits
  • 8 files changed
  • 2 contributors

Commits on Mar 24, 2018

  1. Copy the full SHA
    d56c711 View commit details

Commits on Sep 11, 2018

  1. Measure name matching (#37)

    * fixes broken query helper tests
    
    * adds tests for new VALID_FILTER_RE regex
    
    * makes VALID_FILTER_RE tests pass
    
    * remove coverage files, ignore dir
    MarcioPorto authored and jazzido committed Sep 11, 2018
    Copy the full SHA
    be90abc View commit details
  2. Copy the full SHA
    736a12e View commit details

Commits on Sep 13, 2018

  1. Copy the full SHA
    7e33619 View commit details

Commits on Feb 8, 2019

  1. Copy the full SHA
    fb2310e View commit details

Commits on Feb 11, 2019

  1. tweaking travis conf

    jazzido committed Feb 11, 2019
    Copy the full SHA
    175ba80 View commit details
  2. Copy the full SHA
    b98f2fb View commit details

Commits on Mar 29, 2019

  1. Copy the full SHA
    d5ebe24 View commit details
  2. install bundler in travis

    jazzido authored Mar 29, 2019
    Copy the full SHA
    63c552b View commit details

Commits on Apr 22, 2019

  1. Copy the full SHA
    f6d2531 View commit details

Commits on Apr 23, 2019

  1. bump version

    jazzido committed Apr 23, 2019
    Copy the full SHA
    3ddc85c View commit details

Commits on Jun 11, 2019

  1. Update README.md

    jazzido authored Jun 11, 2019
    Copy the full SHA
    4a6325e View commit details

Commits on Feb 9, 2020

  1. Update mondarian-olap

    jazzido committed Feb 9, 2020
    Copy the full SHA
    c91aeb9 View commit details

Commits on Apr 29, 2020

  1. Update .travis.yml

    jazzido authored Apr 29, 2020
    Copy the full SHA
    52f6d69 View commit details
Showing with 37 additions and 11 deletions.
  1. +3 −0 .gitignore
  2. +4 −3 .travis.yml
  3. +5 −1 README.md
  4. +11 −3 lib/mondrian_rest/query_helper.rb
  5. +1 −1 lib/mondrian_rest/version.rb
  6. +2 −2 mondrian-rest.gemspec
  7. +1 −1 spec/api_spec.rb
  8. +10 −0 spec/query_builder_spec.rb
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -2,3 +2,6 @@
*.log
spec/fixtures/foodmart/
spec/fixtures/webshop.sqlite
coverage
Gemfile.lock

7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -3,11 +3,12 @@ language: ruby
before_install:
- gem update --system
- gem install bundler
- gem install jbundler
jdk:
- oraclejdk8
- openjdk10
- oraclejdk11
- oraclejdk12
rvm:
- jruby-9.1.13.0
- jruby-9.2.5.0
env:
- JRUBY_OPTS=--debug

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,11 @@ See [`mondrian-rest-demo`](https://github.com/jazzido/mondrian-rest-demo) and [`

[`mondrian-rest-ui`](https://github.com/jazzido/mondrian-rest-ui) is an experimental visualization tool for `mondrian-rest`, inspired by [CubesViewer](https://github.com/jjmontesl/cubesviewer) and [Polestar](https://github.com/vega/polestar).

*NOTE*: `mondrian-rest` expect the `mondrian.olap.SsasCompatibleNaming` Java property is set to `true`. Set a environment variable `JAVA_OPTS="-Dmondrian.olap.SsasCompatibleNaming=true""` to the process that uses `mondrian-rest`.
*NOTE*: `mondrian-rest` expect the `mondrian.olap.SsasCompatibleNaming` Java property is set to `true`. Set a environment variable `JAVA_OPTS="-Dmondrian.olap.SsasCompatibleNaming=true"` to the process that uses `mondrian-rest`.

## In the wild

`mondrian-rest` powers [Datachile](https://es.datachile.io)'s, [DataUSA](https://datausa.io), and other fine websites built by [Datawheel](http://datawheel.us).

## Credits

14 changes: 11 additions & 3 deletions lib/mondrian_rest/query_helper.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ module QueryHelper
VALID_FILTER_OPS = [
'>', '<', '>=', '<=', '=', '<>'
].freeze
VALID_FILTER_RE = /(?<measure>[a-zA-Z0-9\s]+)\s*(?<operand>#{VALID_FILTER_OPS.join("|")})\s*(?<value>-?\d+\.?\d*)/
VALID_FILTER_RE = /(?<measure>[a-zA-Z0-9\-!$%^&*()_+|@#~`{}\[\]:";'?,.\/\s]+)\s*(?<operand>#{VALID_FILTER_OPS.join("|")})\s*(?<value>-?\d+\.?\d*)/
MEMBER_METHODS = %w[Caption Key Name UniqueName].freeze

def unparse_node(node)
@@ -265,11 +265,19 @@ def build_query(cube, options = {})

unless dd.empty?
# Cross join all the drilldowns
axis_exp = dd.join(' * ')
axis_exp = if dd.size == 1
dd
else dd.size > 1
cross = "Crossjoin(#{dd.pop(2).join(', ')})"
while !dd.empty?
cross = "Crossjoin(#{dd.pop}, #{cross})"
end
cross
end

# Apply filters
unless filters.empty?
filter_exp = filters.map { |f| "[Measures].[#{org.olap4j.mdx.MdxUtil.mdxEncodeString(f[:measure])}] #{f[:operand]} #{f[:value]}" }.join(' AND ')
filter_exp = filters.map { |f| "[Measures].[#{f[:measure]}] #{f[:operand]} #{f[:value]}" }.join(' AND ')
axis_exp = "FILTER(#{axis_exp}, #{filter_exp})"
end

2 changes: 1 addition & 1 deletion lib/mondrian_rest/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Mondrian
module REST
VERSION = "1.0.0"
VERSION = "1.0.4"
end
end
4 changes: 2 additions & 2 deletions mondrian-rest.gemspec
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
s.require_paths = ["lib", "lib/jars"]


s.add_runtime_dependency 'mondrian-olap', ["~> 0.8.0"]
s.add_runtime_dependency 'grape', '~> 1.0', '>= 1.0.0'
s.add_runtime_dependency 'mondrian-olap', [">= 1.1.0"]
s.add_runtime_dependency 'grape', '~> 1.2', '>= 1.2.3'
s.add_runtime_dependency 'writeexcel', '~> 1.0', '>= 1.0.5'
s.add_runtime_dependency 'activesupport', '~> 5.1', '>= 5.1.5'

2 changes: 1 addition & 1 deletion spec/api_spec.rb
Original file line number Diff line number Diff line change
@@ -189,7 +189,7 @@ def app
get '/cubes/Sales/aggregate?drilldown[]=Time.Month&drilldown[]=Customers.City&measures[]=Store%20Sales&debug=true'
r = JSON.parse(last_response.body)
expect(r.has_key?('mdx')).to be(true)
expect(r['mdx']).to eq("SELECT {[Measures].[Store Sales]} ON COLUMNS,\n[Time].[Time].[Month].Members * [Customers].[Customers].[City].Members ON ROWS\nFROM [Sales]")
expect(r['mdx']).to eq("SELECT {[Measures].[Store Sales]} ON COLUMNS,\nCrossjoin([Time].[Time].[Month].Members, [Customers].[Customers].[City].Members) ON ROWS\nFROM [Sales]")
end

it "should not include the generated MDX in the response if debug not given or if debug=false" do
10 changes: 10 additions & 0 deletions spec/query_builder_spec.rb
Original file line number Diff line number Diff line change
@@ -158,4 +158,14 @@ def error!(*args)
expect(q.to_mdx).to eq("SELECT {[Measures].[Store Invoice]} ON COLUMNS,\n{[Top Sellers]} ON ROWS\nFROM [Warehouse]")
end
end

describe "VALID_FILTER_RE" do
it "should match measures with special characters (except '<', '>' and '=')" do
m = QueryHelper::VALID_FILTER_RE.match(" \"#$%&'()*+,-./:;?@[\]^_`{|}~ > 100")
expect(m["measure"]).to eq(" \"#$%&'()*+,-./:;?@[\]^_`{|}~ ")

m = QueryHelper::VALID_FILTER_RE.match("#<=># > 100")
expect(m["measure"]).not_to eq("#<=># ")
end
end
end