From 2f12ac7ea4ab96ba3af8a9d1d0941e13f5fb16b8 Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 6 Feb 2019 11:17:23 -0500 Subject: [PATCH 1/4] #315 - export all follows as CSV --- src/components/user_settings/user_settings.js | 5 ++++- src/services/api/api.service.js | 5 ++++- .../backend_interactor_service/backend_interactor_service.js | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index ef9398f6..cb0ad9f3 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -238,7 +238,10 @@ const UserSettings = { exportFollows () { this.enableFollowsExport = false this.$store.state.api.backendInteractor - .fetchFriends({id: this.$store.state.users.currentUser.id}) + .fetchFriends({ + id: this.$store.state.users.currentUser.id, + isExport: true + }) .then((friendList) => { this.exportPeople(friendList, 'friends.csv') setTimeout(() => { this.enableFollowsExport = true }, 2000) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index d4d52ab1..cf0c2eb2 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -247,11 +247,14 @@ const fetchUser = ({id, credentials}) => { .then((data) => parseUser(data)) } -const fetchFriends = ({id, page, credentials}) => { +const fetchFriends = ({id, page, isExport, credentials}) => { let url = `${FRIENDS_URL}?user_id=${id}` if (page) { url = url + `&page=${page}` } + if (isExport !== undefined) { + url = url + `&export=${isExport}` + } return fetch(url, { headers: authHeaders(credentials) }) .then((data) => data.json()) .then((data) => data.map(parseUser)) diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index ed7d4b49..423aeba5 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -10,8 +10,8 @@ const backendInteractorService = (credentials) => { return apiService.fetchConversation({id, credentials}) } - const fetchFriends = ({id, page}) => { - return apiService.fetchFriends({id, page, credentials}) + const fetchFriends = ({id, page, isExport = false}) => { + return apiService.fetchFriends({id, page, isExport, credentials}) } const fetchFollowers = ({id, page}) => { From a3a9949a21f69a21c4bd27cccfa2bc0ed1b0d323 Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 6 Feb 2019 13:18:54 -0500 Subject: [PATCH 2/4] #315 - clean up the request --- src/services/api/api.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index cf0c2eb2..df920573 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -252,7 +252,7 @@ const fetchFriends = ({id, page, isExport, credentials}) => { if (page) { url = url + `&page=${page}` } - if (isExport !== undefined) { + if (isExport) { url = url + `&export=${isExport}` } return fetch(url, { headers: authHeaders(credentials) }) From 312841717619e397c7cb3255c1cc3e66c0a1044e Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 7 Feb 2019 09:57:16 -0500 Subject: [PATCH 3/4] #315 - separate export and fetch follows logic --- src/components/user_settings/user_settings.js | 5 ++--- src/services/api/api.service.js | 13 +++++++++---- .../backend_interactor_service.js | 5 +++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index cb0ad9f3..a2a23c6f 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -238,9 +238,8 @@ const UserSettings = { exportFollows () { this.enableFollowsExport = false this.$store.state.api.backendInteractor - .fetchFriends({ - id: this.$store.state.users.currentUser.id, - isExport: true + .exportFriends({ + id: this.$store.state.users.currentUser.id }) .then((friendList) => { this.exportPeople(friendList, 'friends.csv') diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index df920573..24ff0f74 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -247,14 +247,18 @@ const fetchUser = ({id, credentials}) => { .then((data) => parseUser(data)) } -const fetchFriends = ({id, page, isExport, credentials}) => { +const fetchFriends = ({id, page, credentials}) => { let url = `${FRIENDS_URL}?user_id=${id}` if (page) { url = url + `&page=${page}` } - if (isExport) { - url = url + `&export=${isExport}` - } + return fetch(url, { headers: authHeaders(credentials) }) + .then((data) => data.json()) + .then((data) => data.map(parseUser)) +} + +const exportFriends = ({id, credentials}) => { + let url = `${FRIENDS_URL}?user_id=${id}&export=true` return fetch(url, { headers: authHeaders(credentials) }) .then((data) => data.json()) .then((data) => data.map(parseUser)) @@ -539,6 +543,7 @@ const apiService = { fetchConversation, fetchStatus, fetchFriends, + exportFriends, fetchFollowers, followUser, unfollowUser, diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index 423aeba5..c2d1617e 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -14,6 +14,10 @@ const backendInteractorService = (credentials) => { return apiService.fetchFriends({id, page, isExport, credentials}) } + const exportFriends = ({id}) => { + return apiService.exportFriends({id, credentials}) + } + const fetchFollowers = ({id, page}) => { return apiService.fetchFollowers({id, page, credentials}) } @@ -78,6 +82,7 @@ const backendInteractorService = (credentials) => { fetchStatus, fetchConversation, fetchFriends, + exportFriends, fetchFollowers, followUser, unfollowUser, From bd24c615d1278ce9af459e9117eb0176db06b890 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 7 Feb 2019 09:59:12 -0500 Subject: [PATCH 4/4] #315 - revert changes --- .../backend_interactor_service/backend_interactor_service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index c2d1617e..80c5cc5e 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -10,8 +10,8 @@ const backendInteractorService = (credentials) => { return apiService.fetchConversation({id, credentials}) } - const fetchFriends = ({id, page, isExport = false}) => { - return apiService.fetchFriends({id, page, isExport, credentials}) + const fetchFriends = ({id, page}) => { + return apiService.fetchFriends({id, page, credentials}) } const exportFriends = ({id}) => {