Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
fixed max logs
Browse files Browse the repository at this point in the history
  • Loading branch information
leftmove committed May 27, 2024
1 parent eecfc14 commit d8e697e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions routers/lib/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ def find_specific_log(query):
return result


max_logs = 100


def add_log(cik, message, name="", identifier=""):
if isinstance(message, dict):
log_string = (
Expand All @@ -164,8 +167,7 @@ def add_log(cik, message, name="", identifier=""):
logs.update_one(
{"cik": cik},
{
"$push": {"logs": {"$each": logs_string}},
"$set": {"logs": {"$slice": -100}},
"$push": {"logs": {"$each": logs_string, "$slice": -max_logs}},
},
)

Expand All @@ -182,7 +184,7 @@ def add_logs(cik, formatted_logs):

logs.update_one(
{"cik": cik},
{"$push": {"logs": {"$each": logs_split}}, "$set": {"logs": {"$slice": -100}}},
{"$push": {"logs": {"$each": logs_split, "$slice": -max_logs}}},
)


Expand Down

0 comments on commit d8e697e

Please sign in to comment.