File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 SavedDataset,
55 Comment,
66 ViewHistory,
7+ User,
78} = require ( "../models" ) ;
89const COUCHDB_BASE_URL =
910 process . env . COUCHDB_BASE_URL || "https://neurojson.org/io" ;
@@ -205,11 +206,11 @@ const addComment = async (req, res) => {
205206// get comments for a dataset
206207const getComments = async ( req , res ) => {
207208 try {
208- const { couch_db , ds_id } = req . query ;
209+ const { dbName , datasetId } = req . params ;
209210 const dataset = await Dataset . findOne ( {
210211 where : {
211- couch_db,
212- ds_id,
212+ couch_db : dbName ,
213+ ds_id : datasetId ,
213214 } ,
214215 } ) ;
215216
@@ -219,6 +220,12 @@ const getComments = async (req, res) => {
219220
220221 const comments = await Comment . findAll ( {
221222 where : { dataset_id : dataset . id } ,
223+ include : [
224+ {
225+ model : User ,
226+ attributes : [ "id" , "username" ] ,
227+ } ,
228+ ] ,
222229 order : [ [ "created_at" , "DESC" ] ] ,
223230 } ) ;
224231 res . status ( 200 ) . json ( { comments } ) ;
You can’t perform that action at this time.
0 commit comments