Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
blendb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
C3SL
blendb
Commits
17dc567f
There was a problem fetching the pipeline summary.
Commit
17dc567f
authored
7 years ago
by
Lucas Fernandes de Oliveira
Browse files
Options
Downloads
Plain Diff
Merge branch 'issue/18' into 'master'
Issue
#18
: Add subdimensions reading to configParser See merge request
!16
parents
54c2a9ff
62cf5bcb
Branches
Branches containing commit
No related tags found
1 merge request
!16
Issue #18: Add subdimensions reading to configParser
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/util/configParser.spec.ts
+90
-2
90 additions, 2 deletions
src/util/configParser.spec.ts
src/util/configParser.ts
+32
-6
32 additions, 6 deletions
src/util/configParser.ts
with
122 additions
and
8 deletions
src/util/configParser.spec.ts
+
90
−
2
View file @
17dc567f
...
...
@@ -20,7 +20,24 @@
import
{
expect
}
from
"
chai
"
;
import
{
ConfigParser
,
ViewParsingOptions
}
from
"
./configParser
"
;
import
{
ConfigParser
,
ViewParsingOptions
,
DimensionStrOptions
}
from
"
./configParser
"
;
import
{
Dimension
}
from
"
../core/dimension
"
;
import
{
RelationType
}
from
"
../common/types
"
;
function
strToRelationType
(
str
:
string
):
RelationType
{
switch
(
str
)
{
case
"
day
"
:
return
RelationType
.
DAY
;
case
"
month
"
:
return
RelationType
.
MONTH
;
case
"
year
"
:
return
RelationType
.
YEAR
;
case
"
dayofweek
"
:
return
RelationType
.
DAYOFWEEK
;
default
:
return
RelationType
.
NONE
;
}
}
describe
(
"
configParser utility library
"
,
()
=>
{
let
metMap
=
new
Map
();
...
...
@@ -46,7 +63,7 @@ describe("configParser utility library", () => {
expect
(
error
).
to
.
be
.
true
;
});
it
(
"
should throw expection for inexistent
metric
"
,
()
=>
{
it
(
"
should throw expection for inexistent
dimension
"
,
()
=>
{
let
opts
:
ViewParsingOptions
=
{
alias
:
"
Test
"
,
data
:
"
test
"
,
...
...
@@ -67,4 +84,75 @@ describe("configParser utility library", () => {
expect
(
error
).
to
.
be
.
true
;
});
it
(
"
should throw expection for inexistent parent for subdimension
"
,
()
=>
{
let
opts
:
DimensionStrOptions
=
{
name
:
"
dim:-1
"
,
dataType
:
"
integer
"
,
parent
:
"
dim:0
"
,
relation
:
"
none
"
};
let
dims
:
Dimension
[]
=
[];
let
error
:
boolean
=
false
;
try
{
ConfigParser
.
parseDimOpts
(
opts
,
dims
);
}
catch
(
e
)
{
error
=
true
;
expect
(
e
.
message
).
to
.
be
.
equal
(
"
[Parsing error] Parent for subdimension
"
+
opts
.
name
+
"
not found
"
);
}
expect
(
error
).
to
.
be
.
true
;
});
it
(
"
should parse subdimentions relations correctly
"
,
()
=>
{
let
opts
:
DimensionStrOptions
[]
=
[
{
name
:
"
dim:day
"
,
dataType
:
"
integer
"
,
parent
:
"
dim:0
"
,
relation
:
"
day
"
},
{
name
:
"
dim:month
"
,
dataType
:
"
integer
"
,
parent
:
"
dim:0
"
,
relation
:
"
month
"
},
{
name
:
"
dim:year
"
,
dataType
:
"
integer
"
,
parent
:
"
dim:0
"
,
relation
:
"
year
"
},
{
name
:
"
dim:dayofweek
"
,
dataType
:
"
integer
"
,
parent
:
"
dim:0
"
,
relation
:
"
dayofweek
"
},
{
name
:
"
dim:none
"
,
dataType
:
"
integer
"
,
parent
:
"
dim:0
"
,
relation
:
"
none
"
},
];
let
dims
:
Dimension
[]
=
[
new
Dimension
({
name
:
"
dim:a
"
,
dataType
:
"
date
"
}),
new
Dimension
({
name
:
"
dim:0
"
,
dataType
:
"
date
"
})
];
for
(
let
i
=
0
;
i
<
opts
.
length
;
++
i
)
{
let
parsed
=
ConfigParser
.
parseDimOpts
(
opts
[
i
],
dims
);
expect
(
parsed
.
name
).
to
.
be
.
equal
(
opts
[
i
].
name
);
expect
(
parsed
.
dataType
).
to
.
be
.
equal
(
opts
[
i
].
dataType
);
expect
(
parsed
.
parent
).
to
.
be
.
equal
(
dims
[
1
]);
expect
(
parsed
.
relation
).
to
.
be
.
equal
(
strToRelationType
(
opts
[
i
].
relation
));
}
});
});
This diff is collapsed.
Click to expand it.
src/util/configParser.ts
+
32
−
6
View file @
17dc567f
...
...
@@ -39,7 +39,7 @@ interface MetricStrOptions {
dataType
:
string
;
}
interface
DimensionStrOptions
{
export
interface
DimensionStrOptions
{
name
:
string
;
dataType
:
string
;
parent
?:
string
;
...
...
@@ -100,7 +100,7 @@ export class ConfigParser {
}
for
(
let
i
=
0
;
i
<
dimensionsOpts
.
length
;
++
i
)
{
let
dim
=
new
Dimension
(
this
.
parseDimOpts
(
dimensionsOpts
[
i
]));
let
dim
=
new
Dimension
(
this
.
parseDimOpts
(
dimensionsOpts
[
i
]
,
parsed
.
dimensions
));
parsed
.
dimensions
.
push
(
dim
);
dimMap
.
set
(
dim
.
name
,
dim
);
}
...
...
@@ -152,9 +152,20 @@ export class ConfigParser {
return
viewOpt
;
}
p
rivate
static
parseDimOpts
(
opts
:
DimensionStrOptions
):
DimensionOptions
{
p
ublic
static
parseDimOpts
(
opts
:
DimensionStrOptions
,
dims
:
Dimension
[]
):
DimensionOptions
{
if
(
opts
.
parent
||
opts
.
relation
)
{
throw
new
Error
(
"
Sub dimensions not implemented in config parser !!!
"
);
for
(
let
i
=
0
;
i
<
dims
.
length
;
++
i
)
{
if
(
dims
[
i
].
name
===
opts
.
parent
)
{
return
{
name
:
opts
.
name
,
dataType
:
opts
.
dataType
,
parent
:
dims
[
i
],
relation
:
this
.
strToRelationType
(
opts
.
relation
)
};
}
}
throw
new
Error
(
"
[Parsing error] Parent for subdimension
"
+
opts
.
name
+
"
not found
"
);
}
return
{
name
:
opts
.
name
,
...
...
@@ -184,4 +195,19 @@ export class ConfigParser {
return
AggregationType
.
NONE
;
}
}
private
static
strToRelationType
(
str
:
string
):
RelationType
{
switch
(
str
)
{
case
"
day
"
:
return
RelationType
.
DAY
;
case
"
month
"
:
return
RelationType
.
MONTH
;
case
"
year
"
:
return
RelationType
.
YEAR
;
case
"
dayofweek
"
:
return
RelationType
.
DAYOFWEEK
;
default
:
return
RelationType
.
NONE
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment