Skip to content

Commit

Permalink
Merge pull request #67 from cinxdy/master
Browse files Browse the repository at this point in the history
[FEAT] Implement my analysis Backend & Service module & Click button …
  • Loading branch information
lamb0711 authored Feb 10, 2022
2 parents 41fb4a1 + 04edaca commit 4c4ef9b
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 2,731 deletions.
14 changes: 14 additions & 0 deletions fe-backend/models/myAnalysis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const chartSchema = new Schema({
userEmail: String,
keyword: String,
savedDate: Date,
analysisDate: Date,
chartImg: String,
activity: String,
jsonDocId: Number,
},{collection: 'myAnalysis'});

const conn = require("../connection/textMiningConn");
module.exports = conn.model("myAnalysis", chartSchema);
43 changes: 41 additions & 2 deletions fe-backend/module/textMiningQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const router = express.Router();

router.post("/uploadDict", uploadDict);
router.post("/getPreprocessedData",getPreprocessedData);
router.post("/uploadChart", uploadChart);

const usersDict = require("../models/usersDict");
const preprocessing = require("../models/preprocessing");


const myAnalysis = require("../models/myAnalysis");

async function uploadDict(req, res) {
let userEmail = req.body.userEmail;
Expand Down Expand Up @@ -71,5 +71,44 @@ async function uploadDict(req, res) {
.json(new Res(false, "successfully saved doc HashKeys", null));
});
}

async function uploadChart(req, res) {
if(req.body.userEmail == null || req.body.chartImg == null)
return res.status(400).json(
new Res(false, "Request body does not exist",null)
);

// console.log('req',req);
// let doc = {
// 'userEmail': req.body.userEmail,
// 'keyword': req.body.keyword,
// 'savedDate': req.body.savedDate,
// 'analysisDate': req.body.savedDate,
// 'chartImg': req.body.chartImg,
// 'activity': req.body.activity,
// 'jsonDocId': req.body.jsonDocId,
// };
let doc=req.body;

myAnalysis.findOneAndUpdate(
{ $and: [{ userEmail: req.body.userEmail },{ analysisDate: req.body.analysisDate},]},
{"$set":doc},
{ upsert: true, returnNewDocument: true }
).then((result)=>{
console.log("successfully uploaded");
return res
.status(200)
.json(
new Res(true, "successfully uploaded",null)
);
}).catch((err) => {
console.log(err);
return res
.status(400)
.json(
new Res(false, "Upload to mongo DB Failed",null)
);;
});
}

module.exports = router;
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"react-modal": "^3.14.3",
"rxjs": "~6.6.3",
"rxjs-compat": "^6.6.3",
"save-svg-as-png": "^1.4.17",
"sunburst-chart": "^1.11.2",
"tslib": "^2.0.3",
"uikit": "^3.6.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@
<figure id="scatter"></figure>
<figure id="tree"></figure>
<figure id="ldavis"></figure>
</section>

<button (click)="saveSvg()" *ngIf="isDataAnalysised">분석함 저장</button>
<button (click)="downloadPng()" *ngIf="isDataAnalysised">차트 이미지 다운로드</button>

</section>

</section>
</div>
Loading

0 comments on commit 4c4ef9b

Please sign in to comment.