Skip to content

Commit

Permalink
add mohtly contributors count to send_statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelGeo committed Oct 31, 2024
1 parent b0d4be8 commit 52862d1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/mergin/stats/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def send_statistics():
"workspaces_count": current_app.ws_handler.workspace_count(),
"last_change": str(last_change_item.updated) + "Z" if last_change_item else "",
"server_version": current_app.config["VERSION"],
"monthly_contributors": current_app.ws_handler.monthly_contributors_count(),
}

try:
Expand Down
7 changes: 7 additions & 0 deletions server/mergin/sync/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ def workspace_count():
"""
pass

@staticmethod
def monthly_contributors_count():
"""
Return number of workspace contributors in current month and year
"""
pass


class AbstractProjectHandler(ABC):
@abstractmethod
Expand Down
4 changes: 4 additions & 0 deletions server/mergin/sync/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ def filter_projects(
def workspace_count():
return 1

@staticmethod
def monthly_contributors_count():
return 0

def projects_query(self, name=None, workspace=None):
ws = self.factory_method()
query = db.session.query(
Expand Down
2 changes: 2 additions & 0 deletions server/mergin/tests/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ def test_send_statistics(app, caplog):
"workspaces_count",
"last_change",
"server_version",
"monthly_contributors",
}
assert data["workspaces_count"] == 1
assert data["service_uuid"] == app.config["SERVICE_ID"]
assert data["licence"] == "ce"
assert data["monthly_contributors"] == 0

# repeated action does not do anything
task = send_statistics.s().apply()
Expand Down

0 comments on commit 52862d1

Please sign in to comment.