Skip to content

Commit

Permalink
server side fix ideo
Browse files Browse the repository at this point in the history
  • Loading branch information
squidgetx committed Dec 17, 2022
1 parent 0a392ae commit d7040ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ app.use(express.static(path.join(__dirname, "public")));
app.use(cors());

app.post("/fresh_tweets", auth.middleware, function (req, res, next) {
fetch_tweets(req.body.username, req.body.ideo).then((r) => res.json(r));
fetch_tweets(req.body.username, req.body.ideo)
.then((r) => res.json(r))
.catch((err) => next(new Error(err.message)));
});

app.post("/log_tweets", auth.middleware, function (req, res, next) {
Expand Down
7 changes: 3 additions & 4 deletions server/lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ const middleware = function (req, res, next) {

/* Register a new user in the study */
const register = async function (user, install_code) {
return await db.any(
"INSERT INTO users VALUES ($1, $2, NULL, 0)",
return await db.any("INSERT INTO users VALUES ($1, $2, NULL, 0)", [
user,
install_code
);
install_code,
]);
};

module.exports = {
Expand Down
3 changes: 2 additions & 1 deletion server/lib/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = async function (username, mock_ideo) {
);
ideo = ideo_result.ideo;
}
console.log("got mock ideo value ", mock_ideo);
const ideo_sign = Math.sign(ideo);

// todo: handle retweets
Expand All @@ -46,7 +47,7 @@ module.exports = async function (username, mock_ideo) {
results = await db.any(
`
with relevant_tweets as (
select * from tweets where id in (
select * from tweets where author_id in (
select id from elites where sign(ideo) = $1
) and referenced_tweet_type is null
)
Expand Down

0 comments on commit d7040ab

Please sign in to comment.