From ec8de74b63c21e7433a5c5770a67b2129b84e0c2 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Thu, 18 Oct 2018 23:06:53 +0200
Subject: [PATCH] Tmp wrapper scripts to fetch data from gitlab /
 opencollective

---
 tmp.py => tmp_gitlab.py |  0
 tmp_oc.py               | 26 ++++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
 rename tmp.py => tmp_gitlab.py (100%)
 create mode 100644 tmp_oc.py

diff --git a/tmp.py b/tmp_gitlab.py
similarity index 100%
rename from tmp.py
rename to tmp_gitlab.py
diff --git a/tmp_oc.py b/tmp_oc.py
new file mode 100644
index 0000000..1fd6fe4
--- /dev/null
+++ b/tmp_oc.py
@@ -0,0 +1,26 @@
+from contributions.sources import opencollective
+
+
+def retrieve_transactions(collective_id):
+    per_page = 50
+    offset = 0
+    while True:
+        transactions = opencollective.retrieve_transactions(
+            collective_id, limit=per_page, offset=offset
+        )
+        for t in transactions:
+            yield t
+        if len(transaction) < per_page:  # last page
+            break
+
+
+collective_id = 18778
+collective_slug = "funkwhale"
+
+for i, transaction in enumerate(retrieve_transactions(collective_id)):
+    print(
+        "Importing contribution in database",
+        transaction["id"],
+        transaction["description"],
+    )
+    opencollective.import_transaction_as_contribution(transaction, collective_slug)
-- 
GitLab