linguabot commited on
Commit
8ff00f6
·
verified ·
1 Parent(s): 3375c6a

Upload folder using huggingface_hub

Browse files
models/RefinityAnnotation.js CHANGED
@@ -7,6 +7,7 @@ const RefinityAnnotationSchema = new mongoose.Schema({
7
  category: { type: String, required: true },
8
  comment: { type: String },
9
  correction: { type: String },
 
10
  }, { timestamps: true });
11
 
12
  module.exports = mongoose.model('RefinityAnnotation', RefinityAnnotationSchema);
 
7
  category: { type: String, required: true },
8
  comment: { type: String },
9
  correction: { type: String },
10
+ createdBy: { type: String }, // Optional: username who created the annotation
11
  }, { timestamps: true });
12
 
13
  module.exports = mongoose.model('RefinityAnnotation', RefinityAnnotationSchema);
models/TutorialRefinityAnnotation.js CHANGED
@@ -7,6 +7,7 @@ const TutorialRefinityAnnotationSchema = new mongoose.Schema({
7
  category: { type: String, required: true },
8
  comment: { type: String },
9
  correction: { type: String },
 
10
  }, { timestamps: true });
11
 
12
  module.exports = mongoose.model('TutorialRefinityAnnotation', TutorialRefinityAnnotationSchema);
 
7
  category: { type: String, required: true },
8
  comment: { type: String },
9
  correction: { type: String },
10
+ createdBy: { type: String }, // Optional: username who created the annotation
11
  }, { timestamps: true });
12
 
13
  module.exports = mongoose.model('TutorialRefinityAnnotation', TutorialRefinityAnnotationSchema);
routes/refinity.js CHANGED
@@ -1719,7 +1719,9 @@ router.post('/annotations', async (req, res) => {
1719
  if (!versionId || start === undefined || end === undefined || !category) {
1720
  return res.status(400).json({ error: 'Missing required fields' });
1721
  }
1722
- const row = await RefinityAnnotation.create({ versionId, start, end, category, comment, correction });
 
 
1723
  res.json(row);
1724
  } catch (e) {
1725
  res.status(500).json({ error: 'Failed to create annotation' });
 
1719
  if (!versionId || start === undefined || end === undefined || !category) {
1720
  return res.status(400).json({ error: 'Missing required fields' });
1721
  }
1722
+ // Store creator if provided in header
1723
+ const createdBy = req.headers['x-user-name'] ? String(req.headers['x-user-name']).toLowerCase() : undefined;
1724
+ const row = await RefinityAnnotation.create({ versionId, start, end, category, comment, correction, ...(createdBy ? { createdBy } : {}) });
1725
  res.json(row);
1726
  } catch (e) {
1727
  res.status(500).json({ error: 'Failed to create annotation' });
routes/tutorial-refinity.js CHANGED
@@ -749,7 +749,9 @@ router.get('/annotations', async (req, res) => {
749
  router.post('/annotations', async (req, res) => {
750
  try {
751
  const { versionId, start, end, category, comment, correction } = req.body || {};
752
- const annotation = await TutorialRefinityAnnotation.create({ versionId, start, end, category, comment, correction });
 
 
753
  res.json(annotation);
754
  } catch (e) {
755
  res.status(500).json({ error: 'Failed to create annotation' });
 
749
  router.post('/annotations', async (req, res) => {
750
  try {
751
  const { versionId, start, end, category, comment, correction } = req.body || {};
752
+ // Store creator if provided in header
753
+ const createdBy = req.headers['x-user-name'] ? String(req.headers['x-user-name']).toLowerCase() : undefined;
754
+ const annotation = await TutorialRefinityAnnotation.create({ versionId, start, end, category, comment, correction, ...(createdBy ? { createdBy } : {}) });
755
  res.json(annotation);
756
  } catch (e) {
757
  res.status(500).json({ error: 'Failed to create annotation' });