From 1ee1e10e728274e4672f87e2fa3b0d1376208e6a Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 7 Oct 2024 11:08:02 +0200 Subject: [PATCH] remove endpoints in fastify && update model --- app/cron_ai_score.py | 5 ++- .../__pycache__/score_model.cpython-310.pyc | Bin 3999 -> 3902 bytes app/ml_models/score_model.py | 15 +++----- fastify/app.js | 4 -- fastify/get-community-stats/server.js | 27 ------------- fastify/get-moderators/server.js | 22 ----------- fastify/get-user-data/server.js | 22 ----------- fastify/get-user-stats/server.js | 36 ------------------ 8 files changed, 8 insertions(+), 123 deletions(-) delete mode 100755 fastify/get-community-stats/server.js delete mode 100755 fastify/get-moderators/server.js delete mode 100755 fastify/get-user-data/server.js delete mode 100755 fastify/get-user-stats/server.js diff --git a/app/cron_ai_score.py b/app/cron_ai_score.py index 563a355..c961cb5 100644 --- a/app/cron_ai_score.py +++ b/app/cron_ai_score.py @@ -243,7 +243,7 @@ async def download_data(ticker, con, start_date, end_date, skip_downloading): if not df_copy.empty: with open(file_path, 'wb') as file: file.write(orjson.dumps(df_copy.to_dict(orient='records'))) - print(df_copy) + return df_copy except Exception as e: @@ -266,6 +266,7 @@ async def chunked_gather(tickers, con, skip_downloading, chunk_size): for chunk in tqdm(chunks(tickers, chunk_size)): # Create tasks for each chunk + print(f"chunk size: {len(chunk)}") tasks = [download_data(ticker, con, start_date, end_date, skip_downloading) for ticker in chunk] # Await the results for the current chunk chunk_results = await asyncio.gather(*tasks) @@ -357,7 +358,7 @@ async def run(): AND symbol NOT LIKE '%.%' AND symbol NOT LIKE '%-%' """) - warm_start_symbols = ['AAPL'] #[row[0] for row in cursor.fetchall()] + warm_start_symbols = ['PEP'] #[row[0] for row in cursor.fetchall()] print(f'Warm Start Training: Total Tickers {len(warm_start_symbols)}') await warm_start_training(warm_start_symbols, con, skip_downloading) diff --git a/app/ml_models/__pycache__/score_model.cpython-310.pyc b/app/ml_models/__pycache__/score_model.cpython-310.pyc index 9846f133fe714b30d3128b6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{RDkL~)dUoFG! z)OKYCbM9MeP^W&l;`+`wZ~6``Y7DcpGYBj%D { fastify.addHook("onRequest", corsMiddleware); //fastify.register(require('./mixpanel/server'), { mixpanel, UAParser }); -fastify.register(require("./get-user-stats/server"), { pb }); -fastify.register(require("./get-community-stats/server"), { pb }); -fastify.register(require("./get-moderators/server"), { pb }); -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 }); diff --git a/fastify/get-community-stats/server.js b/fastify/get-community-stats/server.js deleted file mode 100755 index c0875e5..0000000 --- a/fastify/get-community-stats/server.js +++ /dev/null @@ -1,27 +0,0 @@ -module.exports = function (fastify, opts, done) { - const pb = opts.pb; - - fastify.get('/get-community-stats', async (request, reply) => { - let output; - let totalUsers = 0; - let totalPosts = 0; - let totalComments = 0; - - try { - totalUsers = (await pb.collection("users").getList(1, 1))?.totalItems; - totalPosts = (await pb.collection("posts").getList(1, 1))?.totalItems; - totalComments = (await pb.collection("comments").getList(1, 1))?.totalItems; - - - output = { totalUsers, totalPosts, totalComments }; - - } catch (e) { - console.error(e); - output = { totalUsers, totalPosts, totalComments }; - } - - reply.send({ items: output }); - }); - - done(); -}; diff --git a/fastify/get-moderators/server.js b/fastify/get-moderators/server.js deleted file mode 100755 index 3fc07ad..0000000 --- a/fastify/get-moderators/server.js +++ /dev/null @@ -1,22 +0,0 @@ -// Declare a route -module.exports = function (fastify, opts, done) { - - const pb = opts.pb; - - fastify.get('/get-moderators', async (request, reply) => { - let output; - - try { - output = await pb.collection("moderators").getFullList({ - expand: 'user' - }) - } - catch(e) { - output = []; - } - - reply.send({ items: output }) - }); - - done(); -}; \ No newline at end of file diff --git a/fastify/get-user-data/server.js b/fastify/get-user-data/server.js deleted file mode 100755 index c708ec1..0000000 --- a/fastify/get-user-data/server.js +++ /dev/null @@ -1,22 +0,0 @@ -// Declare a route -module.exports = function (fastify, opts, done) { - - const pb = opts.pb; - - fastify.post('/get-user-data', async (request, reply) => { - const data = request.body; - const userId = data?.userId - let output; - - try { - output = await pb.collection("users").getOne(userId) - } - catch(e) { - output = {}; - } - - reply.send({ items: output }) - }); - - done(); -}; \ No newline at end of file diff --git a/fastify/get-user-stats/server.js b/fastify/get-user-stats/server.js deleted file mode 100755 index 858fd16..0000000 --- a/fastify/get-user-stats/server.js +++ /dev/null @@ -1,36 +0,0 @@ -// Declare a route -module.exports = function (fastify, opts, done) { - - const pb = opts.pb; - - fastify.post('/get-user-stats', async (request, reply) => { - const data = request.body; - const userId = data?.userId; - - let output; - - try { - const getNumberOfPosts = await pb.collection("posts").getList(1,1, { - filter: `user="${userId}"`, - }); - const numberOfPosts = getNumberOfPosts?.totalItems - - - const getNumberOfComments = await pb.collection("comments").getList(1,1, { - filter: `user="${userId}"`, - }); - const numberOfComments = getNumberOfComments?.totalItems - - output = {numberOfPosts, numberOfComments} - console.log(output) - - } - catch(e) { - output = {}; - } - - reply.send({ items: output }) - }); - - done(); -}; \ No newline at end of file