Skip to content

Instantly share code, notes, and snippets.

View sminnee's full-sized avatar

Sam Minnée sminnee

View GitHub Profile
@sminnee
sminnee / cloc.sh
Created September 19, 2023 23:49
Example of a script that calls cloc on a codebase to get a useful result
cloc --exclude-dir=node_modules,migrations,build,.mypy_cache --fullpath --not-match-d=server/app/static --not-match-f=package-lock.json --exclude-ext=csv,svg .
echo "
---- TESTS ONLY (INLCUDED IN ABOVE) ----
"
cloc --exclude-dir=node_modules,migrations,build,.mypy_cache --fullpath --not-match-d=server/app/static --match-f="(tests/)|(test_[^/]*.py)|(\.test\.ts)|(\.cy\.ts)" .
diff --git a/client/src/services/files.ts b/client/src/services/files.ts
index 416a1710b..00dc54f84 100644
--- a/client/src/services/files.ts
+++ b/client/src/services/files.ts
@@ -2,7 +2,7 @@ import { callAPI } from "services/util";
import { getAPIAuthentication } from "services/auth";
import PQueue from "p-queue";
-const uploadQueue = new PQueue({ concurrency: 4 });
+export const uploadQueue = new PQueue({ concurrency: 4 });
diff --git a/client/src/AppRoutes.tsx b/client/src/AppRoutes.tsx
index 351779730..6f56d9c08 100644
--- a/client/src/AppRoutes.tsx
+++ b/client/src/AppRoutes.tsx
@@ -204,9 +204,11 @@ const ContentRoutes = () => (
</AuthenticatedRoute>
}
/>
- {PropertyDetailRoute(RouteURLs.VIEW_PROPERTY)}
- {PropertyDetailRoute(RouteURLs.VIEW_PROPERTY_TAB)}
diff --git a/server/app_util/tests/data.py b/server/app_util/tests/data.py
index 7d8c03ebd..bd868f291 100644
--- a/server/app_util/tests/data.py
+++ b/server/app_util/tests/data.py
@@ -173,6 +173,11 @@ def utc(dt: datetime):
return dt.astimezone(pytz.utc)
+def utc_date(dt: datetime):
+ """Convert a timezone-aware datetime to UTC and then return the date only. Test helper."""
from typing import Dict, Union, List, Optional
from app_util.tests.base import BaseTestCase
from app_util.tests.util import send_request
class MockApiClient:
"""A mock API client that returns a summary of the request made in its JSON response."""
def get(self, url: str, data: dict, **headers):
return MockApiClient.Response({"method": "get", "url": url, "data": data, "headers": headers})
from typing import Dict, Union, List, Optional
from app_util.tests.base import BaseTestCase
from app_util.tests.util import send_request
class MockApiClient:
"""A mock API client that returns a summary of the request made in its JSON response"""
def get(self, url: str, data: dict, **headers):
return MockApiClient.Response({"method": "get", "url": url, "data": data, "headers": headers})
diff --git a/server/integrations/models.py b/server/integrations/models.py
index 56dfbcbc1..e837b237a 100644
--- a/server/integrations/models.py
+++ b/server/integrations/models.py
@@ -43,7 +43,7 @@ class Integration(models.Model):
class Meta:
ordering = ["organization", "type"]
- unique_together = [["organization", "type", "domain"]]
+ unique_together = [["organization", "type", "domain", "owner"]]
diff --git a/server/simpro/api/auth.py b/server/simpro/api/auth.py
index 76b12354..7b031d4d 100644
--- a/server/simpro/api/auth.py
+++ b/server/simpro/api/auth.py
@@ -80,6 +80,9 @@ def save_user_auth(user: User, organization: Organization, build_domain: str, ac
class IsValidSimproRequest(BasePermission):
def has_permission(self, request: Request, view: View):
+ # Fetch this before getting request data, otherwise it fails
+ body = request._request.body
diff --git a/server/facilities/models/assets.py b/server/facilities/models/assets.py
index 4f05dfec..f982e579 100644
--- a/server/facilities/models/assets.py
+++ b/server/facilities/models/assets.py
@@ -26,9 +26,9 @@ class AssetEstimatedAge(Enum):
GREATER_THAN_TWENTY = '20+ years'
class AssetDuplicateTaskMode(Enum):
- link = 'link'
- duplicate = 'duplicate'
diff --git a/src/connector.ts b/src/connector.ts
index c0aeaab0..2f0ecc99 100644
--- a/src/connector.ts
+++ b/src/connector.ts
@@ -70,9 +70,7 @@ export default class Connector extends SocketClient {
onLogin = () => {
console.log('app.on login reconnect')
- if (this.multiplayerActive) {
- this.reconnect()