Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mohtly contributors count to send_statistics #316

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
MarcelGeo marked this conversation as resolved.
Show resolved Hide resolved

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
Loading