codecov-io: # [Codecov](https://codecov.io/gh/ownaginatious/mixpanel-jql/pull/18?src=pr&el=h1) Report
> Merging [#18](https://codecov.io/gh/ownaginatious/mixpanel-jql/pull/18?src=pr&el=desc) into [master](https://codecov.io/gh/ownaginatious/mixpanel-jql/commit/cad22fecf6220e3857dec5de122c8df8810c9737?src=pr&el=desc) will **increase** coverage by `0.04%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/ownaginatious/mixpanel-jql/pull/18/graphs/tree.svg?width=650&token=xJsxO2WgJp&height=150&src=pr)](https://codecov.io/gh/ownaginatious/mixpanel-jql/pull/18?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master      #18      +/-   ##
==========================================
+ Coverage   87.08%   87.13%   +0.04%     
==========================================
  Files           2        2              
  Lines         271      272       +1     
  Branches       71       70       -1     
==========================================
+ Hits          236      237       +1     
  Misses         24       24              
  Partials       11       11
```


| [Impacted Files](https://codecov.io/gh/ownaginatious/mixpanel-jql/pull/18?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [mixpanel\_jql/query.py](https://codecov.io/gh/ownaginatious/mixpanel-jql/pull/18/diff?src=pr&el=tree#diff-bWl4cGFuZWxfanFsL3F1ZXJ5LnB5) | `86.94% <100%> (+0.04%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/ownaginatious/mixpanel-jql/pull/18?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/ownaginatious/mixpanel-jql/pull/18?src=pr&el=footer). Last update [cad22fe...cc5066a](https://codecov.io/gh/ownaginatious/mixpanel-jql/pull/18?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

diff --git a/mixpanel_jql/query.py b/mixpanel_jql/query.py
index 919894f..768da83 100644
--- a/mixpanel_jql/query.py
+++ b/mixpanel_jql/query.py
@@ -394,19 +394,19 @@ class JQL(object):
         return jql
 
     def group_by(self, keys, accumulator):
-        if not isinstance(keys, (tuple, set, list)):
-            keys = [keys]
-        jql = self._clone()
-        jql.operations += ("groupBy([%s], %s)"
-                           % (", ".join(_f(k) for k in keys), _f(accumulator)),)
-        return jql
+        return self._group_by(False, keys, accumulator)
 
     def group_by_user(self, keys, accumulator):
+        return self._group_by(True, keys, accumulator)
+
+    def _group_by(self, user, keys, accumulator):
         if not isinstance(keys, (tuple, set, list)):
             keys = [keys]
+        if not isinstance(accumulator, Reducer):
+            accumulator = _f(accumulator)
         jql = self._clone()
-        jql.operations += ("groupByUser([%s], %s)"
-                           % (", ".join(_f(k) for k in keys), _f(accumulator)),)
+        op = "groupByUser" if user else "groupBy"
+        jql.operations += ("%s([%s], %s)" % (op, ", ".join(_f(k) for k in keys), accumulator),)
         return jql
 
     def query_plan(self):

mixpanel_jql.exceptions.InvalidJavaScriptText
Hi, first of all thanks for this project!

I'm trying to run the first example and I'm getting:
`mixpanel_jql.exceptions.InvalidJavaScriptText: Must be a text type (str, unicode) or wrapped as raw(str||unicode)`

I'm runnning Python 3.6.5 on Ubuntu 18.04
diff --git a/tests/test_transformations.py b/tests/test_transformations.py
index f66c218..e7f3dfc 100644
--- a/tests/test_transformations.py
+++ b/tests/test_transformations.py
@@ -63,6 +63,12 @@ class TestGroupTransformations(unittest.TestCase):
             'function main() { return Events({}).'
             '%s([e.a, e.b, e.c], e.properties.some_accessor); }' % expected_function)
 
+        self.assertEqual(
+            str(grouper([
+                raw('e.a'), raw('e.b'), raw('e.c')], Reducer.count())),
+            'function main() { return Events({}).'
+            '%s([e.a, e.b, e.c], mixpanel.reducer.count()); }' % expected_function)
+
         # Non iterable key.
         self.assertEqual(
             str(grouper(raw('e.a'), raw('e.properties.some_accessor'))),

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
charset-normalizer==2.0.12
EditorConfig==0.17.0
idna==3.10
ijson==3.3.0
importlib-metadata==4.8.3
iniconfig==1.1.1
jsbeautifier==1.15.4
-e git+https://github.com/ownaginatious/mixpanel-jql.git@cad22fecf6220e3857dec5de122c8df8810c9737#egg=mixpanel_jql
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
requests==2.27.1
six==1.17.0
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0

name: mixpanel-jql
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - charset-normalizer==2.0.12
      - editorconfig==0.17.0
      - idna==3.10
      - ijson==3.3.0
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - jsbeautifier==1.15.4
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - requests==2.27.1
      - six==1.17.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zipp==3.6.0
prefix: /opt/conda/envs/mixpanel-jql

tests/test_transformations.py::TestGroupTransformations::test_group_by tests/test_transformations.py::TestGroupTransformations::test_group_by_user
tests/test_transformations.py::TestAccessorOnlyTransformations::test_filter tests/test_transformations.py::TestAccessorOnlyTransformations::test_map tests/test_transformations.py::TestAccessorOnlyTransformations::test_reduce tests/test_transformations.py::TestAccessorOnlyTransformations::test_sort_asc tests/test_transformations.py::TestAccessorOnlyTransformations::test_sort_desc
mixpanel_jql/query.py
mixpanel_jql/query.py