Skip to content

Commit

Permalink
fix : fixes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
dennyabrain committed Dec 7, 2021
1 parent 89773d1 commit f42ad40
Show file tree
Hide file tree
Showing 18 changed files with 2,498 additions and 10 deletions.
11 changes: 11 additions & 0 deletions annotators/annotation-ui/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 annotators/annotation-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"grommet-icons": "^4.6.2",
"i18next": "^21.4.0",
"js-file-download": "^0.4.12",
"local-storage": "^2.0.0",
"lodash": "^4.17.21",
"lorem-ipsum": "^2.0.4",
"react": "^17.0.1",
Expand Down
35 changes: 31 additions & 4 deletions annotators/annotation-ui/src/components/atoms/SimplePost.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from "react";
import { Box, Text, Image, Anchor } from "grommet";
import { Box, Text, Image, Anchor, Video } from "grommet";
import { Clock, Alert, Checkmark } from "grommet-icons";

export function SimplePost({ post, annotationStatus }) {
Expand All @@ -9,6 +9,7 @@ export function SimplePost({ post, annotationStatus }) {
.split(",")
.map((photo) => photo.slice(1, photo.length - 1)),
urls: post.urls.split(",").map((url) => url.slice(1, url.length - 1)),
role: post.role,
};

return (
Expand All @@ -22,6 +23,7 @@ export function SimplePost({ post, annotationStatus }) {
pad="medium"
gap={"xsmall"}
height={"medium"}
overflow="scroll"
>
<Box direction={"row"} gap={"small"} align={"center"}>
<Text color={"dark-4"}>{post.id}</Text>
Expand Down Expand Up @@ -55,8 +57,8 @@ export function SimplePost({ post, annotationStatus }) {
</div>
{transformedPost.photos ? (
<Box
height={"fit-content"}
width={"fit-content"}
height={"small"}
width={"small"}
direction={"row-responsive"}
>
{transformedPost.photos.map((photo, ix) => (
Expand All @@ -68,7 +70,7 @@ export function SimplePost({ post, annotationStatus }) {
>
<Image
key={ix}
fit={"contain"}
fit={"cover"}
alignSelf={"start"}
src={photo}
/>
Expand All @@ -77,6 +79,31 @@ export function SimplePost({ post, annotationStatus }) {
))}
</Box>
) : null}
{transformedPost.role === "gif" && transformedPost.photos ? (
<Box
height={"small"}
width={"small"}
direction={"row-responsive"}
>
{transformedPost.photos.map((photo, ix) => (
<Box height={"large"} width={"large"}>
<Video
controls="over"
fit="contain"
controls={true}
loop={true}
autoPlay={true}
>
<source
key="video"
src={photo}
type="video/mp4"
/>
</Video>
</Box>
))}
</Box>
) : null}
</Box>
);
}
1 change: 1 addition & 0 deletions annotators/annotation-ui/src/controller/annotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class Annotator {
async sync() {}

getFormStatus(annotations) {
return true;
const { explicit, hate, dimension, ogbv } = annotations;
if ((explicit && hate && dimension && ogbv) != undefined) {
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Posts", "e_twitter_id", {
type: Sequelize.STRING,
});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn("Posts", "e_twitter_id");
},
};
1 change: 1 addition & 0 deletions annotators/backend/sequelize/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
},
e_twitter_id: DataTypes.STRING,
role: DataTypes.ENUM("text", "image", "gif", "video"),
text: DataTypes.STRING,
lang: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const data_en = require("./posts_beta_2_english_100.json");
const data_ta = require("./posts_beta_2_tamil_30.json");

const time_of_run = new Date();
// const time_of_run = new Date("2021-11-26T03:07:14.977Z");
// const time_of_run = new Date("2021-11-26T04:10:43.073Z");
console.log(time_of_run);

module.exports = {
Expand Down Expand Up @@ -35,29 +35,31 @@ module.exports = {
console.log({ brinda_ta });

for (var i = 0; i < data_en.posts.length; i++) {
const post = data_en.posts[i];
await queryInterface.bulkInsert("Posts", [
{
id: uuidv4(),
lang: "en",
role: data_en.posts[i].content_type,
text: data_en.posts[i].tweet,
urls: "",
photos: data_en.posts[i].image_url,
photos: post.image_url.slice(1, post.image_url.length - 1),
createdAt: time_of_run,
updatedAt: time_of_run,
},
]);
}

for (var i = 0; i < data_ta.posts.length; i++) {
const post = data_ta.posts[i];
await queryInterface.bulkInsert("Posts", [
{
id: uuidv4(),
lang: "ta",
role: data_ta.posts[i].content_type,
text: data_ta.posts[i].tweet,
urls: "",
photos: data_ta.posts[i].image_url,
photos: post.image_url.slice(1, post.image_url.length - 1),
createdAt: time_of_run,
updatedAt: time_of_run,
},
Expand Down Expand Up @@ -100,7 +102,7 @@ module.exports = {
{
id: uuidv4(),
userId: brinda_ta.id,
postId: postIDs[i].id,
postId: tamilPostIDs[i].id,
status: "pending",
createdAt: time_of_run,
updatedAt: time_of_run,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"use strict";
const { v4: uuidv4 } = require("uuid");
const { Op } = require("Sequelize");
const generatePassword = require("password-generator");
const data_ta = require("./posts_beta_2_tamil_30.json");

const time_of_run = new Date();
// const time_of_run = new Date("2021-11-26T04:10:43.073Z");
console.log(time_of_run);

module.exports = {
up: async (queryInterface, Sequelize) => {
const doubleUserId = await queryInterface.sequelize.query(
`SELECT id from Users WHERE username="brinda_ta";`
);
const user = doubleUserId[0];
console.log({ brinda: user });

const doubleTamilPostIds = await queryInterface.sequelize.query(
`SELECT id from Posts WHERE lang="ta";`
);
const tamilPostIDs = doubleTamilPostIds[0];
console.log(`New tamil posts count : ${tamilPostIDs.length}`);
console.log(`inserting for tamil user`);
for (var i = 0; i < tamilPostIDs.length; i++) {
await queryInterface.bulkInsert("UserPostAllocations", [
{
id: uuidv4(),
userId: user[0].id,
postId: tamilPostIDs[i].id,
status: "pending",
createdAt: time_of_run,
updatedAt: time_of_run,
},
]);
}
},

down: async (queryInterface, Sequelize) => {},
};

0 comments on commit f42ad40

Please sign in to comment.