Skip to content

Commit

Permalink
feat: Added number of servers to env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelloeater committed Sep 10, 2023
1 parent 8eba564 commit 274b604
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
EMAIL=[email protected]
SITE_ADDRESS=localhost
# Your Domain here
LOG_LEVEL=30
LOG_LEVEL=0
#10 Debug 20 Info 30 Warn
POSTGRES_DB=gatus
POSTGRES_USER=username
POSTGRES_PASSWORD=password

POSTGRES_HOSTNAME_GATUS=gatusdb
POSTGRES_HOSTNAME_MONITORING=monitoringdb
POSTGRES_DB_MONITORING=postgres
TEST_MODE=1
NUMBER_OF_SERVERS=50
1 change: 1 addition & 0 deletions cloud-init.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ write_files:
POSTGRES_HOSTNAME_GATUS=gatusdb
POSTGRES_HOSTNAME_MONITORING=monitoringdb
POSTGRES_DB_MONITORING=postgres
NUMBER_OF_SERVERS=50

- path: /root/Caddyfile
content: |
Expand Down
11 changes: 8 additions & 3 deletions fedi_gatus/shared/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ def __init__(self, *args, **kwargs):
def get_single_record(self) -> dict:
return self.select().get()

def get_top_lemmy_instances(self, count=25) -> list[Model]:
# TODO Add env var for count
def get_top_lemmy_instances(self) -> list[Model]:
NUMBER_OF_SERVERS = int(os.getenv("NUMBER_OF_SERVERS"))
logging.info("Number of Rows:" + str(DbAccess.select().count()))
d = DbAccess.select().where(DbAccess.software_name == "Lemmy").order_by(DbAccess.stats_monthly_active_users).limit(count)
d = (
DbAccess.select()
.where(DbAccess.software_name == "Lemmy")
.order_by(DbAccess.stats_monthly_active_users)
.limit(NUMBER_OF_SERVERS)
)
info = []
for i in d:
info.append(i)
Expand Down

0 comments on commit 274b604

Please sign in to comment.