Skip to content

Commit 1faad31

Browse files
Merge pull request #2603 from IFRCGo/feature/migration-considerations-to-api
PER data-fetcher functionality v1.0
2 parents 23490b9 + 7a4cde1 commit 1faad31

4 files changed

Lines changed: 482 additions & 1 deletion

File tree

assets

docs/go-artifacts.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,78 @@ docker compose run --rm serve ./manage.py spectacular --file ./assets/openapi-sc
4040
- In `go-api`
4141
- **Update the submodule reference** in your `go-api` PR.
4242
- In the corresponding **`go-api` Pull Request**, include the link to the `go-api-artifacts` PR as a *related PR* so reviewers can track both changes together.
43+
44+
## Submodule Pointer Workflow
45+
46+
Keep CI green by ensuring the parent repo points to a submodule commit that exists on the remote.
47+
48+
- Update submodule content and push:
49+
```bash
50+
cd assets
51+
git checkout -b update-artifacts
52+
# make changes (e.g., regenerate schema)
53+
git add -A
54+
git commit -m "Update artifacts"
55+
git push origin update-artifacts
56+
# open PR in IFRCGo/go-api-artifacts and merge to main
57+
git checkout main && git pull
58+
cd -
59+
```
60+
- Record new submodule commit in parent:
61+
```bash
62+
# ensure the submodule worktree is on the merged commit
63+
cd assets && git checkout main && git pull && cd -
64+
git add assets
65+
git commit -m "Update assets submodule pointer"
66+
git push origin <your-go-api-branch>
67+
```
68+
- GitHub Actions checkout settings (recommended):
69+
```yaml
70+
- uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
submodules: recursive
74+
```
75+
76+
Notes
77+
- Avoid amending/rebasing submodule commits that the parent already references; make a new commit instead.
78+
- Ensure submodule commit is on `origin/main` (or a ref CI can fetch) before updating the parent pointer.
79+
80+
## Submodule Commands Cheat Sheet
81+
82+
Common commands you’ll use with `assets` submodule:
83+
84+
- Initialize submodules after clone:
85+
```bash
86+
git submodule update --init --recursive
87+
```
88+
- Sync `.gitmodules` config to local submodule metadata:
89+
```bash
90+
git submodule sync
91+
```
92+
- Check the submodule commit pointer:
93+
```bash
94+
git submodule status
95+
```
96+
- Move submodule to latest commit from its remote tracking branch:
97+
```bash
98+
git submodule update --remote assets
99+
git add assets
100+
git commit -m "Sync assets to latest remote commit"
101+
```
102+
- Pin submodule to a specific commit (e.g., after checkout):
103+
```bash
104+
cd assets
105+
git checkout <commit-or-branch>
106+
cd -
107+
git add assets
108+
git commit -m "Update assets submodule pointer"
109+
```
110+
- Switch submodule remote to SSH (avoid HTTPS prompts):
111+
```bash
112+
git config -f .gitmodules submodule.assets.url git@github.com:IFRCGo/go-api-artifacts.git
113+
git submodule sync
114+
cd assets && git remote set-url origin git@github.com:IFRCGo/go-api-artifacts.git && cd -
115+
git add .gitmodules assets
116+
git commit -m "Use SSH for artifacts submodule"
117+
```

main/urls.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@
217217
url(r"^api/v2/secondarysector", ProjectSecondarySectors.as_view()),
218218
url(r"^api/v2/projectstatus", ProjectStatuses.as_view()),
219219
url(r"^api/v2/learningtype", LearningTypes.as_view()),
220+
# Consolidated PER endpoints
221+
url(r"^api/v2/per-map-data", per_views.PerMapDataView.as_view()),
222+
url(r"^api/v2/per-assessments-processed", per_views.PerAssessmentsProcessedView.as_view()),
223+
url(r"^api/v2/per-dashboard-data", per_views.PerDashboardDataView.as_view()),
220224
# url(r"^api/v2/create_field_report/", api_views.CreateFieldReport.as_view()),
221225
# url(r"^api/v2/update_field_report/(?P<pk>\d+)/", api_views.UpdateFieldReport.as_view()),
222226
url(r"^get_auth_token", GetAuthToken.as_view()),

0 commit comments

Comments
 (0)