Problem to solve
Using REST-API and/or GraphQL I want to fetch one commit per day for the last 90 days. If there’s no commit for one day it’s also ok… currently I’ve two approaches:
-
For each day, call the commits API (Commits API | GitLab), set per_page=1 and use since/until for the specific day. For each commit, use the Repository files API (Repository files API | GitLab) to get the source for each commit. This would cause 90 calls to the commits API and following this, 90 calls to the Repository files API.
-
Using the commits API (Commits API | GitLab), set per_page=1 and use since/until for the specific day. Based on the commits, create a GraphQL and send it to the Gitlab instance to retrieve the content for the corresponding commits. This would cause 90 calls to the commits API and 2 or 3 GraphQL queries because of the complexity because I’ve to add a separate “project-query” like:
{
query1:project(fullPath: "/my/project") {
repository {
blobs(paths: "myfile" ref: "1234abcda") {
nodes {
rawBlob
}
}
}
},
query2:project(fullPath: "/my/project") {
repository {
blobs(paths: "myfile" ref: "1234abcdb") {
nodes {
rawBlob
}
}
}
},
query3:project(fullPath: "/my/project") {
repository {
blobs(paths: "myfile" ref: "1234abcdc") {
nodes {
rawBlob
}
}
}
},
...
}
The reason I want one commit per day is because the file I’m requesting is updated every 5 minutes via API calls already.
The most “critical” thing is the commits API. In the commits API there’s already a since/until flag. In my case a “interval” parameter would be helpful where I can specify the “interval” between the commits returned. For example setting “interval” to 84600s means one commit within the given since/until. But unfortunately I don’t know if it would be possible…
Is anyone knowing a better approach?
Versions
Please select whether options apply, and add the version information.
- Self-managed
- GitLab.com SaaS
Versions
- GitLab (Web:
/help
or self-managed system information):