Skip to content

Commit

Permalink
feat: Users can submit slurs to Uli
Browse files Browse the repository at this point in the history
We've tested the lexicon with the two partner organizations. The metadata fields may change in the future but not dramatically. 

For reference:
- Annotation guideline (for meaning of each label): https://docs.google.com/document/d/18H4TlLFB2GXK054oMj1uXVJ2OCFW08Gi/edit
- partner annotations here: https://docs.google.com/spreadsheets/d/15YrV8Q-5PTorHRo71ZBkdL0bePPaUNC9FTU41ET91V4/edit#gid=0


These are the fields that we need for now:
| Field Name    | Field Type |  Possible Values |  Optional?|
| ------------- | ---------- |----------------- |------- |
| Level of Severity  |  Single option | low, mid, high  | No |
| Casual  |  Binary | Yes, No  | No |
| Appropriated  |  Binary | Yes, No  | No |
| If, Appropriated is it by community or others?  |  Binary | Community, Others  | yes |
| What makes it problematic?  |  Text |        | yes |
| Category of Abuse |   pick multiple |  gendered, sexualized, religion, ethnicity , political affiliation, caste, class, body shaming,  abelist,  sexual identity,  other | pick at least one, at most 4 |

---------

Co-authored-by: Denny <[email protected]>
  • Loading branch information
aatmanvaidya and dennyabrain authored Oct 13, 2023
1 parent 64c0b84 commit d4ee30d
Show file tree
Hide file tree
Showing 34 changed files with 4,255 additions and 155 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('slurs', {
id: {
allowNull: false,
primaryKey: true,
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
},
userId: {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
references: {
model:'users',
key: 'id',
}
},
label: {
type: Sequelize.STRING,
},
levelOfSeverity : {
type: Sequelize.ENUM(['low', 'medium', 'high']),
},
casual : {
type: Sequelize.BOOLEAN,
},
appropriated: {
type: Sequelize.BOOLEAN,
},
appropriationContext: {
type: Sequelize.BOOLEAN,
},
labelMeaning: {
type: Sequelize.TEXT,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('slurs');
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('categories', {
id: {
allowNull: false,
primaryKey: true,
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
},
slurId: {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
references: {
model: 'slurs',
key: 'id',
},
},
category: {
type: Sequelize.ENUM([
"gendered",
"sexualized",
"religion",
"ethnicity",
"political affiliation",
"caste",
"class",
"body shaming",
"ableist",
"sexual identity",
"other",
]),
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('categories');
},
};
47 changes: 47 additions & 0 deletions browser-extension/api-server/db/models/category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use strict";
const { Model } = require("sequelize");

module.exports = (sequelize, DataTypes) => {
class category extends Model {
static associate(models) {
// Define associations here if needed
}
}

category.init(
{
id: {
primaryKey: true,
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
},
slurId: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
foreignKey: true,
allowNull: false,
},
category: {
type: DataTypes.ENUM([
"gendered",
"sexualized",
"religion",
"ethnicity",
"political affiliation",
"caste",
"class",
"body shaming",
"ableist",
"sexual identity",
"other",
]),
},
},
{
sequelize,
modelName: "category",
}
);

return category;
};
59 changes: 59 additions & 0 deletions browser-extension/api-server/db/models/slur.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"use strict";
const { Model } = require("sequelize");

module.exports = (sequelize, DataTypes) => {
class slur extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// Define associations here if needed
slur.hasMany(models.category, {
foreignKey: "slurId",
as: "categories",
});
}
}

slur.init(
{
id: {
primaryKey: true,
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
},
userId: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
foreignKey: true,
allowNull: false,
},
label: {
type: DataTypes.STRING,
},
levelOfSeverity: {
type: DataTypes.ENUM(['low', 'medium', 'high']),
},
casual: {
type: DataTypes.BOOLEAN,
},
appropriated: {
type: DataTypes.BOOLEAN,
},
appropriationContext: {
type: DataTypes.BOOLEAN,
},
labelMeaning: {
type: DataTypes.TEXT,
},
},
{
sequelize,
modelName: "slur",
}
);

return slur;
};
1 change: 1 addition & 0 deletions browser-extension/api-server/db/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = (sequelize, DataTypes) => {
// define association here
user.hasOne(models.preference);
user.hasMany(models.post);
user.hasMany(models.slur);
}
}
user.init(
Expand Down
Loading

0 comments on commit d4ee30d

Please sign in to comment.