Skip to content

Commit

Permalink
epss fix (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
P-T-I authored Jun 28, 2024
1 parent fec39f7 commit 06c4047
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CveXplore/.schema_version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.8",
"version": "1.9",
"rebuild_needed": true
}
7 changes: 5 additions & 2 deletions CveXplore/core/database_actions/db_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DatabaseAction(object):

actions = collections.namedtuple("Actions", "InsertOne UpdateOne")(0, 1)

def __init__(self, action: actions, doc: dict):
def __init__(self, action: actions, doc: dict, upsert: bool = True):
"""
Create a DatabaseAction object.
Expand All @@ -23,6 +23,7 @@ def __init__(self, action: actions, doc: dict):
"""
self.action = action
self.doc = doc
self.upsert = upsert

@property
def entry(self):
Expand All @@ -37,4 +38,6 @@ def entry(self):
if self.action == self.actions.InsertOne:
return InsertOne(self.doc)
elif self.action == self.actions.UpdateOne:
return UpdateOne({"id": self.doc["id"]}, {"$set": self.doc}, upsert=True)
return UpdateOne(
{"id": self.doc["id"]}, {"$set": self.doc}, upsert=self.upsert
)
3 changes: 1 addition & 2 deletions CveXplore/core/database_maintenance/sources_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,7 @@ def process_item(self, item):
if epss is not None:
self.queue.put(
DatabaseAction(
action=DatabaseAction.actions.UpdateOne,
doc=epss,
action=DatabaseAction.actions.UpdateOne, doc=epss, upsert=False
)
)

Expand Down
2 changes: 1 addition & 1 deletion requirements/modules/mongodb.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pymongo>=4.5.0
pymongo>=4.8.0

0 comments on commit 06c4047

Please sign in to comment.