File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 22from fastapi import FastAPI , HTTPException , status
33from fastapi .middleware .cors import CORSMiddleware
44from crawlProcess import exec # Assuming these are in other files
5- from service .privousChats import getAllDetailsById , getAllPreviousKeywords
5+ from service .privousChats import getAllDetailsById , getAllPreviousKeywords , deletePreviousCrawl
66# from testdb import getKeywordAll , getKeywordById # Assuming these are in other files
77from schema .keywordSchema import Keyword , KeywordOut # Assuming these are in other files
88from schema .fullDetailsSchema import FullSchema , FullSchemaOut
@@ -175,4 +175,8 @@ def crawl():
175175 "message" : f"Failed to run crawler: { str (e )} " ,
176176 "urls_sent" : urls ,
177177 "keyword_id" : keywordId
178- }
178+ }
179+
180+ @app .delete ("/api/v1/keyword/{id}" )
181+ async def deletePrevious (id :str ):
182+ return await deletePreviousCrawl (id )
Original file line number Diff line number Diff line change 11from model .keyword import keyword_collection
2+ from model .siteData import siteDataCollection
3+ from model .summary import summaryCollection
24from bson import ObjectId
5+ from fastapi .responses import JSONResponse
36
47
58
@@ -75,3 +78,22 @@ async def getAllPreviousKeywords():
7578 print (result )
7679 return result
7780
81+
82+
83+ async def deletePreviousCrawl (id ):
84+ try :
85+ await keyword_collection .delete_many ({"_id" : ObjectId (id )})
86+ await siteDataCollection .delete_many ({"keywordId" : ObjectId (id )})
87+ await summaryCollection .delete_many ({"keywordId" : ObjectId (id )})
88+
89+ return JSONResponse (
90+ status_code = 200 ,
91+ content = {"status" : "success" }
92+ )
93+ except Exception as e :
94+ print (e )
95+ return JSONResponse (
96+ status_code = 400 ,
97+ content = {"status" : "fail" }
98+ )
99+
You can’t perform that action at this time.
0 commit comments