MCPcopy Create free account
hub / github.com/geekcomputers/Python / DBFetcherLess

Method DBFetcherLess

insta_monitering/insta_datafetcher.py:417–441  ·  view source on GitHub ↗
(self, limit, date)

Source from the content-addressed store, hash-verified

415 return ujson.dumps(postval)
416
417 def DBFetcherLess(self, limit, date):
418 mainlist = []
419 postval = {}
420 try:
421 postval["posts"] = None
422 if limit.isdigit() == False and date.isdigit() == False:
423 raise Exception
424 limit = int(limit)
425 date = int(date)
426 doc = (
427 self._collection.find({"date": {"$lt": date}})
428 .limit(limit)
429 .sort("date", pymongo.DESCENDING)
430 )
431 for i in doc:
432 del i["_id"]
433 mainlist.append(i)
434 postval["posts"] = mainlist[::-1]
435 postval["status"] = True
436 except Exception as err:
437 print(f"error : {err}\n")
438 print("error::", sys.exc_info()[1])
439 postval["status"] = False
440 finally:
441 return ujson.dumps(postval)
442
443 def __del__(self):
444 self.mon.close()

Callers 1

getMethod · 0.95

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected