Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
a34021b
Fix get_random_ingredients to return basil instead of parsley
MM674294 Apr 23, 2026
7f61878
Add sys.path configuration to Sphinx documentation builder
MM674294 Apr 23, 2026
34026d6
Update sys.path configuration for Sphinx documentation and enable aut…
stuti-2005 Apr 23, 2026
0877d5e
Add initial documentation for lumache module with function and except…
stuti-2005 Apr 23, 2026
3f5a802
Add backend modules to autosummary in API documentation
stuti-2005 Apr 23, 2026
670e0d2
Refactor API documentation structure and update sys.path for Sphinx
stuti-2005 Apr 23, 2026
0e4c818
Refactor Sphinx configuration and update project metadata for UNIsoc
stuti-2005 Apr 23, 2026
b914fcd
Add initial documentation for models and serializer modules
stuti-2005 Apr 23, 2026
4bd26b8
Update MOCK_MODULES to include 'views' and 'authentication' for impro…
stuti-2005 Apr 23, 2026
5b11371
Add initial views documentation with autodata inclusion
stuti-2005 Apr 23, 2026
1bf2679
Add views documentation with currentmodule and autodata directives
MM674294 Apr 24, 2026
4c515bb
Merge branch 'main' of https://github.com/SETAP-UniSoc/code-documenta…
MM674294 Apr 24, 2026
0b04ddc
Remove 'models', 'serializer', and 'views' from MOCK_MODULES for clar…
stuti-2005 Apr 24, 2026
e06ff11
Update sys.path in conf.py for relative path and add views.py for API…
stuti-2005 Apr 24, 2026
51e71f9
Refactor views documentation to include automodule directive with mem…
stuti-2005 Apr 24, 2026
155016f
Update serializer.rst to include automodule directives for models and…
stuti-2005 Apr 24, 2026
05c0e8c
Refactor views.py to replace imports with mocked dependencies for doc…
stuti-2005 Apr 24, 2026
1afdbe3
Add models and serializers for UNIsoc application
stuti-2005 Apr 24, 2026
08e1dbf
Refactor mock module list in conf.py to include missing Django auth m…
stuti-2005 Apr 24, 2026
8338b03
Refactor serializer.py to use MagicMock for models and serializers in…
stuti-2005 Apr 24, 2026
be7b8e3
Update MOCK_MODULES in conf.py to include additional Django auth modules
stuti-2005 Apr 24, 2026
3dffe30
Update models and serializers documentation with detailed description…
stuti-2005 Apr 24, 2026
d322cc8
Remove outdated models section from serializer documentation
stuti-2005 Apr 24, 2026
25c0b7e
Refactor conf.py and views.py to remove mock dependencies and impleme…
stuti-2005 Apr 24, 2026
2f26811
Update API reference documentation with correct module paths and form…
stuti-2005 Apr 24, 2026
34244d5
Update Django settings module path in conf.py for correct configuration
stuti-2005 Apr 24, 2026
9338c80
Fix project root path in conf.py for correct module resolution
stuti-2005 Apr 24, 2026
6df9887
Add BASE_DIR to sys.path in conf.py for improved module resolution
stuti-2005 Apr 24, 2026
692843e
Refactor conf.py to define BASE_DIR directly for improved clarity and…
stuti-2005 Apr 24, 2026
22daffa
Update BASE_DIR in conf.py for correct project root path
stuti-2005 Apr 24, 2026
9f6f921
Fix BASE_DIR path in conf.py for correct project root resolution
stuti-2005 Apr 24, 2026
30999c5
Update BASE_DIR in conf.py to use absolute path for correct project r…
stuti-2005 Apr 24, 2026
f8c7807
Update API reference in api.rst for improved clarity and structure
stuti-2005 Apr 24, 2026
a572866
Add autosummary section to api.rst for improved module organization
stuti-2005 Apr 24, 2026
15aa5df
Refactor conf.py to remove Django setup and streamline mock module ha…
stuti-2005 Apr 24, 2026
6bc7e47
Refactor conf.py to streamline mock module handling and ensure correc…
stuti-2005 Apr 24, 2026
1d12425
Add documentation for authentication models and serializers
stuti-2005 Apr 24, 2026
3c32ede
Fix autosummary paths in api.rst to include 'backend.' prefix for cor…
stuti-2005 Apr 24, 2026
7f77b5b
Add generated documentation for authentication models and serializers
stuti-2005 Apr 24, 2026
ccfcb44
Fix event date check in JoinEventView to use start_time for validation
stuti-2005 Apr 24, 2026
75358b7
Fix Sphinx import path in conf.py to correctly point to the backend d…
stuti-2005 Apr 25, 2026
3866e64
Refactor import statements in views.py for clarity and consistency
stuti-2005 Apr 25, 2026
de68dd4
Set Django settings module and initialize Django in conf.py
stuti-2005 Apr 25, 2026
81048bb
Update table of contents in index.rst
stuti-2005 Apr 29, 2026
6839905
Add project scope and objectives documentation
stuti-2005 Apr 29, 2026
653549e
Create requirements document for users and admins
stuti-2005 Apr 29, 2026
e4c5a77
Add implementation documentation
stuti-2005 Apr 29, 2026
e679813
Implement User_ProfileView for user profile updates
stuti-2005 Apr 29, 2026
bcb3135
Remove comment in post method of implementation.rst
stuti-2005 Apr 29, 2026
d503f76
Add setup instructions to documentation
stuti-2005 Apr 29, 2026
6251b43
Add documentation for project components and services
stuti-2005 Apr 29, 2026
692513f
Fix formatting of bash command in setup documentation
stuti-2005 Apr 29, 2026
c102e04
made documentation for setup.rst
stuti-2005 Apr 29, 2026
2797765
added all setup processes to setup.rst
stuti-2005 Apr 29, 2026
a189afc
added all commandds to setup.rst
stuti-2005 Apr 29, 2026
b3c6497
cd
stuti-2005 Apr 29, 2026
f941035
cd
stuti-2005 Apr 29, 2026
4915b76
updated index.rst
stuti-2005 Apr 30, 2026
30cd4d1
updated and documented usage.rst
stuti-2005 Apr 30, 2026
b297a4e
documented usage.rst
stuti-2005 Apr 30, 2026
c86ba10
made documentation for user registartion
stuti-2005 Apr 30, 2026
a8f5052
made documenation for user and admin login
stuti-2005 Apr 30, 2026
455f7ce
made documetation fpor user home page
stuti-2005 Apr 30, 2026
ae1e2e9
documentation for userhomepage
stuti-2005 Apr 30, 2026
e297dd2
documentation for user mysociety page
stuti-2005 Apr 30, 2026
8d0c757
documentatipn for user my events page
stuti-2005 Apr 30, 2026
b687385
documenation for usersettings page
stuti-2005 Apr 30, 2026
a943f6a
cd
stuti-2005 Apr 30, 2026
a0c45a5
documentation for admin events page
stuti-2005 Apr 30, 2026
42da3bc
cd
stuti-2005 Apr 30, 2026
8d88226
cd
stuti-2005 Apr 30, 2026
03a0467
documentation for analytics page
stuti-2005 Apr 30, 2026
0fd7a01
code documentation for event details
stuti-2005 Apr 30, 2026
c3f0188
cd for index.rst
stuti-2005 Apr 30, 2026
39c427b
added backend documentation to index.rst
stuti-2005 Apr 30, 2026
f75a769
cd
stuti-2005 Apr 30, 2026
96adaf3
added conf.py file that was deleted
stuti-2005 Apr 30, 2026
1880cb3
updated the layout of cd
stuti-2005 Apr 30, 2026
bba72bc
cd
stuti-2005 Apr 30, 2026
9989832
styling cd
stuti-2005 Apr 30, 2026
d68f107
cd
stuti-2005 Apr 30, 2026
89eb94a
added endpoint for admin evnts page
stuti-2005 Apr 30, 2026
3f7a05f
added endpoint for event detail view
stuti-2005 Apr 30, 2026
ebfa324
added endpoint for user homepage
stuti-2005 Apr 30, 2026
1015d94
cd
stuti-2005 Apr 30, 2026
02adad4
added endpoint for user login page
stuti-2005 Apr 30, 2026
d3bea19
added endpoint to user my events page
stuti-2005 Apr 30, 2026
89983f1
added endpoimt to register
stuti-2005 Apr 30, 2026
d75e0a0
added endpoint to login
stuti-2005 Apr 30, 2026
5d9ce7f
changed to the right view
stuti-2005 Apr 30, 2026
37dec29
added endpoint to user setttings page
stuti-2005 Apr 30, 2026
49af1d7
cd
stuti-2005 Apr 30, 2026
4a7c863
edited setup.rst
stuti-2005 May 1, 2026
5853259
checking syncing
stuti-2005 May 1, 2026
433dd43
Enhance Admin Analytics documentation with detailed endpoint informat…
stuti-2005 May 5, 2026
6b2a4df
Enhance Admin Events Management documentation with detailed endpoint …
stuti-2005 May 5, 2026
adc6307
Enhance Event Details API documentation with comprehensive endpoint i…
stuti-2005 May 5, 2026
5a20a09
Enhance User Homepage API documentation with detailed endpoint descri…
stuti-2005 May 5, 2026
380cc30
Enhance User Login API documentation with detailed endpoint descripti…
stuti-2005 May 5, 2026
a186695
Enhance User My Events API documentation with detailed endpoint descr…
stuti-2005 May 5, 2026
eef9500
Enhance User My Societies API documentation with detailed endpoint de…
stuti-2005 May 5, 2026
3b0434f
Enhance User Registration API documentation with detailed endpoint de…
stuti-2005 May 5, 2026
a78f6f1
Enhance User Settings API documentation with detailed endpoint descri…
stuti-2005 May 5, 2026
2370b98
Remove suggested improvements section from User Login API documentation
stuti-2005 May 5, 2026
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
Binary file added .DS_Store
Binary file not shown.
18 changes: 13 additions & 5 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
API
===
API Documentation
=================

.. autosummary::
:toctree: generated
This section documents the backend API endpoints.

lumache
Modules
-------

- Authentication (Login, Register)
- Events Management
- Society Management
- Notifications
- Analytics

For full endpoint details, see the Backend Documentation section.
248 changes: 248 additions & 0 deletions docs/source/backend/Admin_Analyticspage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
Admin Analytics
===============

Overview
--------

The **Admin Analytics API** provides analytical insights for society administrators.
It aggregates membership trends, event engagement, and overall activity into a
single endpoint for dashboard visualisation.

This endpoint is designed to support admin dashboards with time-series data and
summary statistics.

Endpoint
--------

.. code-block:: http

GET /api/my-analytics/

**Django Route**

.. code-block:: python

path("my-analytics/", AnalyticsView.as_view(), name="analytics")

Authentication
--------------

- **Required**: Yes
- **Access Level**: Admin users only

Authorization Rules
~~~~~~~~~~~~~~~~~~~

- User must have ``role = "admin"``
- User must be associated with a society

Error Responses
~~~~~~~~~~~~~~~

.. list-table::
:header-rows: 1
:widths: 20 80

* - Status Code
- Description
* - 403
- User is not an admin
* - 404
- No society found for admin

Query Parameters
----------------

.. list-table::
:header-rows: 1
:widths: 20 20 20 40

* - Parameter
- Type
- Default
- Description
* - period
- string
- week
- Time range for analytics aggregation

Allowed Values
~~~~~~~~~~~~~~

- ``week`` → Last 7 days (daily breakdown)
- ``month`` → Last 30 days (daily breakdown)
- ``6months`` → Last 6 months (weekly breakdown)
- ``year`` → Last 12 months (monthly breakdown)

Example Request
~~~~~~~~~~~~~~~

.. code-block:: http

GET /api/my-analytics/?period=month

Response Structure
------------------

.. code-block:: json

{
"labels": ["Mon", "Tue", "Wed"],
"totals": [10, 15, 18],
"live_count": 120,
"total_events": 25,
"events_stats": [
{ "title": "Welcome Event", "attendee_count": 50 }
],
"most_popular": {
"title": "Welcome Event",
"attendee_count": 50
},
"event_attendance": [
{ "title": "Welcome Event", "attendee_count": 50 }
]
}

Response Fields Explained
------------------------

.. list-table::
:header-rows: 1
:widths: 30 70

* - Field
- Description
* - ``labels``
- Time intervals (e.g. days, weeks, months)
* - ``totals``
- Membership count at each interval
* - ``live_count``
- Current active members
* - ``total_events``
- Total number of events created
* - ``events_stats``
- Attendance count per event
* - ``most_popular``
- Event with highest attendance (or null)
* - ``event_attendance``
- Duplicate of ``events_stats`` (for frontend compatibility)

Data Flow & Logic
-----------------

Membership Growth
~~~~~~~~~~~~~~~~~

Membership totals are calculated using:

- ``joined_at <= current_date``
- ``left_at IS NULL OR left_at > current_date``

This ensures historical accuracy and correct handling of users who have left.

Time Bucketing Strategy
~~~~~~~~~~~~~~~~~~~~~~~

.. list-table::
:header-rows: 1
:widths: 20 20 20 40

* - Period
- Interval
- Data Points
- Label Format
* - week
- Daily
- 7
- Mon, Tue
* - month
- Daily
- 30
- 01 Jan
* - 6months
- Weekly
- 26
- Week 12
* - year
- Monthly
- 12
- Jan

Event Analytics
~~~~~~~~~~~~~~~

.. code-block:: python

Count("eventattendance", filter=Q(eventattendance__left_at__isnull=True))

Only active attendees are counted.

Most Popular Event
~~~~~~~~~~~~~~~~~~

- Determined by highest attendee count
- Returns a single event
- Returns ``null`` if no events exist

Implementation Notes
--------------------

Duplicate Query
~~~~~~~~~~~~~~~

.. code-block:: python

society = Society.objects.get(admin=request.user)

This appears twice and should be reused to avoid unnecessary database calls.

Redundant Field
~~~~~~~~~~~~~~~

.. code-block:: json

"event_attendance": list(events_stats)

Duplicates ``events_stats`` and may be removed unless required by the frontend.

Performance Considerations
~~~~~~~~~~~~~~~~~~~~~~~~~

- Membership calculation runs one query per time interval
- Event annotations are executed multiple times
- Consider optimisation using aggregation or caching

Edge Cases
----------

.. list-table::
:header-rows: 1
:widths: 30 70

* - Scenario
- Behaviour
* - No society exists
- Returns 404
* - No events
- ``most_popular = null``
* - No members
- ``totals`` contains zeros
* - Invalid period
- Returns 400

Use Cases
---------

- Admin dashboard visualisation
- Membership growth tracking
- Event engagement analysis
- Identifying popular events

Suggested Improvements
----------------------

- Remove duplicate fields
- Optimise database queries
- Add optional date range filters
- Implement caching (e.g. Redis)
- Include event IDs in responses
Loading