Skip to content

Commit

Permalink
Merge branch 'master' of gh:ssc-oscar/DRE
Browse files Browse the repository at this point in the history
  • Loading branch information
audrism committed Mar 4, 2022
2 parents 18b60b9 + 5d2bb4f commit b057141
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CONTAINER ID IMAGE COMMAND CREATED
docker pull swsc/mern
NID=atutko #change to your own netid
PORT=9290 #change to your own port
docker run -d --name mern$NID -v /home/$NID:/home/$NID -p$PORT:22 -w /home/$NID swsc/mern /bin/startsvc.sh $NID
docker run -d --name mern$NID --link dbWoC:dbWoC -v /home/$NID:/home/$NID -p$PORT:22 -w /home/$NID swsc/mern /bin/startsvc.sh $NID
```
5. From your own laptop open terminal and run (make sure port netid and da server matches)
```
Expand Down
37 changes: 32 additions & 5 deletions client/app/components/Clickhouse/ClickhouseForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class ClickhouseForm extends Component{
this.state = {
start: '',
end: '',
author: '',
project: '',
comment: '',
count: false,
slideValue: 1000,
slideValue: 20,
start_error: false,
end_error: false,
backwards: false,
Expand All @@ -40,7 +43,7 @@ class ClickhouseForm extends Component{
onSubmit(e){
e.preventDefault();
let s_err = false, e_err = false, back = false;
let {start, end, count, slideValue} = this.state;
let {start, end, author, project, comment, count, slideValue} = this.state;
let [new_start, new_end] = this.checkDate(start, end);
if (new_start === "bad start") s_err = true;
if (new_end === "bad end") e_err = true;
Expand All @@ -53,7 +56,7 @@ class ClickhouseForm extends Component{
backwards: back,
})
}
else this.props.history.push(`/clickhouseresult?start=${new_start}&end=${new_end}&count=${count}&limit=${slideValue}`);
else this.props.history.push(`/clickhouseresult?start=${new_start}&end=${new_end}&author=${author}&project=${project}&comment=${comment}&count=${count}&limit=${slideValue}`);
}

onChange(e) {
Expand Down Expand Up @@ -140,7 +143,7 @@ class ClickhouseForm extends Component{
Filling this field while leaving "End time" blank will search
for all commits made at this specific timestamp, rather than a time range.
</UncontrolledTooltip>
<TextFieldGroup
<TextFieldGroup
focus={true}
onChange={this.onChange}
value={this.state.start}
Expand All @@ -159,7 +162,31 @@ class ClickhouseForm extends Component{
field="end"
error={end_err_msg}
/>
<Label className="control-label" target="limit">
<Label>Author</Label>
<TextFieldGroup
label="Author"
focus={true}
onChange={this.onChange}
value={this.state.author}
field="author"
/>
<Label>Project</Label>
<TextFieldGroup
label="Project"
focus={true}
onChange={this.onChange}
value={this.state.project}
field="project"
/>
<Label> Comment</Label>
<TextFieldGroup
label="Comment"
focus={true}
onChange={this.onChange}
value={this.state.comment}
field="comment"
/>
<Label className="control-label" target="limit">
Query Limit
</Label>
<div>
Expand Down
4 changes: 2 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copy this file as config.js in the same folder, with the proper database connection URI.

module.exports = {
db: 'mongodb://dbWoC:27017/WoC',
db_dev: 'mongodb://dbWoC:27017/WoC',
db: 'mongodb://da1:27017/WoC',
db_dev: 'mongodb://da1:27017/WoC',
jwtSecret: 'supersecrettestkeyforsomethingsecret',
clickhouse: 'http://da1.eecs.utk.edu',
showCnt: (process.env.DRE_LOOKUP_PATH ? (process.env.DRE_LOOKUP_PATH + "/showCnt") : '$HOME/lookup/showCnt'),
Expand Down
35 changes: 27 additions & 8 deletions server/routes/api/clickhouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ module.exports = (app) => {
app.get('/api/clickhouse/commits', [
query('start').optional().isInt({min:0}),
query('end').optional().isInt({min:0}),
query('author').optional().isString(),
query('project').optional().isString(),
query('comment').optional().isString(),
query('count').optional().isBoolean(),
query('limit').optional().isInt({min:0})
],
Expand All @@ -24,16 +27,32 @@ module.exports = (app) => {
}

if(typeof req.query.start != 'undefined'){
if(typeof req.query.end != 'undefined'){
where += `time>=${req.query.start} AND time<=${req.query.end}`;
valid_params += 2;
} else {
where += `time=${req.query.start}`;
valid_params++;
where += `time=${req.query.start}`;
valid_params++;
}
if(typeof req.query.end != 'undefined'){
if (where != ' WHERE '){
where += ' AND ';
}
} else {
where = '';
where += `time=${req.query.end}`;
valid_params++;
}
if(typeof req.query.comment != 'undefined'){
if (where != ' WHERE '){ where += ' AND '; }
where += `match(comment, ${req.query.comment})`;
valid_params++;
}
if(typeof req.query.author != 'undefined'){
if (where != ' WHERE '){ where += ' AND '; }
where += `match(author, ${req.query.author})`;
valid_params++;
}
if(typeof req.query.project != 'undefined'){
if (where != ' WHERE '){ where += ' AND '; }
where += `match(project, ${req.query.project})`;
valid_params++;
}
if (where == ' WHERE '){ where += ''; }

if(valid_params <= 0){
return res.status(400).send('Invalid query');
Expand Down

0 comments on commit b057141

Please sign in to comment.