update cron jobs and delete endpoints
This commit is contained in:
parent
d5804c3f38
commit
fd96582203
@ -131,10 +131,10 @@ async def run():
|
||||
print(e)
|
||||
|
||||
|
||||
most_retail_volume = [item for item in most_retail_volume if item['retailStrength'] <= 100]
|
||||
most_retail_volume = sorted(most_retail_volume, key=lambda x: x['traded'], reverse=True)[:100] # top 100 retail volume stocks
|
||||
with open(f"json/retail-volume/data.json", 'w') as file:
|
||||
ujson.dump(most_retail_volume, file)
|
||||
most_retail_volume = [item for item in most_retail_volume if item['retailStrength'] <= 100]
|
||||
most_retail_volume = sorted(most_retail_volume, key=lambda x: x['traded'], reverse=True)[:100] # top 100 retail volume stocks
|
||||
with open(f"json/retail-volume/data.json", 'w') as file:
|
||||
ujson.dump(most_retail_volume, file)
|
||||
|
||||
con.close()
|
||||
etf_con.close()
|
||||
|
||||
@ -82,8 +82,6 @@ async def get_data(ticker, con):
|
||||
async def run():
|
||||
|
||||
con = sqlite3.connect('stocks.db')
|
||||
etf_con = sqlite3.connect('etf.db')
|
||||
|
||||
cursor = con.cursor()
|
||||
cursor.execute("PRAGMA journal_mode = wal")
|
||||
cursor.execute("SELECT DISTINCT symbol FROM stocks")
|
||||
|
||||
@ -3936,4 +3936,4 @@ async def get_newsletter():
|
||||
res = orjson.loads(file.read())
|
||||
except:
|
||||
res = []
|
||||
return res
|
||||
return res
|
||||
@ -1,27 +0,0 @@
|
||||
// Declare a route
|
||||
module.exports = function (fastify, opts, done) {
|
||||
|
||||
const pb = opts.pb;
|
||||
|
||||
fastify.post('/all-watchlists', async (request, reply) => {
|
||||
const data = request.body;
|
||||
const userId = data?.userId;
|
||||
|
||||
let output;
|
||||
|
||||
try {
|
||||
output = await pb.collection("watchlist").getFullList({
|
||||
filter: `user="${userId}"`
|
||||
})
|
||||
}
|
||||
catch(e) {
|
||||
//console.log(e)
|
||||
output = {};
|
||||
}
|
||||
|
||||
reply.send({ items: output })
|
||||
|
||||
});
|
||||
|
||||
done();
|
||||
};
|
||||
@ -68,7 +68,6 @@ fastify.register(require("./get-user-data/server"), { pb });
|
||||
fastify.register(require("./get-all-comments/server"), { pb });
|
||||
fastify.register(require("./get-post/server"), { pb });
|
||||
fastify.register(require("./get-one-post/server"), { pb });
|
||||
fastify.register(require("./update-watchlist/server"), { pb, serialize });
|
||||
fastify.register(require("./get-portfolio-data/server"), { pb });
|
||||
fastify.register(require("./create-portfolio/server"), { pb, serialize });
|
||||
fastify.register(require("./buy-stock/server"), { pb });
|
||||
@ -82,7 +81,6 @@ fastify.register(require("./feedback/server"), { pb });
|
||||
fastify.register(require("./create-watchlist/server"), { pb });
|
||||
fastify.register(require("./delete-watchlist/server"), { pb });
|
||||
fastify.register(require("./edit-name-watchlist/server"), { pb });
|
||||
fastify.register(require("./all-watchlists/server"), { pb });
|
||||
fastify.register(require("./get-notifications/server"), { pb });
|
||||
fastify.register(require("./update-notifications/server"), { pb });
|
||||
fastify.register(require("./create-strategy/server"), { pb });
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
// Declare a route
|
||||
module.exports = function (fastify, opts, done) {
|
||||
const pb = opts.pb;
|
||||
const serialize = opts.serialize;
|
||||
|
||||
fastify.post("/update-watchlist", async (request, reply) => {
|
||||
const data = request.body;
|
||||
|
||||
const userId = data?.userId;
|
||||
const ticker = data?.ticker;
|
||||
const watchListId = data?.watchListId;
|
||||
let output;
|
||||
|
||||
try {
|
||||
const watchList = await pb.collection("watchlist").getOne(watchListId);
|
||||
|
||||
if (watchList?.ticker?.includes(ticker)) {
|
||||
// Remove ticker from the watchlist.
|
||||
const newTickerList = watchList?.ticker.filter(
|
||||
(item) => item !== ticker
|
||||
);
|
||||
output = await pb
|
||||
.collection("watchlist")
|
||||
.update(watchListId, { ticker: newTickerList });
|
||||
} else {
|
||||
// Add ticker to the watchlist.
|
||||
const newTickerList = [...watchList?.ticker, ticker];
|
||||
output = await pb
|
||||
.collection("watchlist")
|
||||
.update(watchListId, { ticker: newTickerList });
|
||||
}
|
||||
} catch (e) {
|
||||
//console.log(e)
|
||||
output = await pb.collection("watchlist").create(
|
||||
serialize({
|
||||
user: userId,
|
||||
ticker: JSON.stringify([ticker]),
|
||||
title: "Favorites",
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
reply.send({ items: output });
|
||||
});
|
||||
|
||||
done();
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user