New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/json exporter #5354
Feature/json exporter #5354
Conversation
Awesome, thanks for working on this extremely important feature! Will check in more detail later. As a general comment relating to exporters, I guess ideally we should aim to push them to Sidekiq for processing - and then email the user a link to the file (auto-expiry of file). But would this be a problem for pods on Heroku for example? Solved with S3 support? |
Yeah, thought about emailing them their data, but can't do it directly with the potential json size. Heroku would probably preclude storing it locally, but uploading could be a solution. Maybe after the file's done processing we create an Export model, which uploads the file to S3 and auto-explodes in like 3 days, James Bond-style.
?? |
In either case, we should consider running the result through gzip, that'll drastically reduce the filesize. |
OK revisiting this, sorry for taking so long. I think initially it's ok if we build 'n' serve the file as it is done now in runtime as long as we don't have large data included - eg comments and posts. When those arrive, we need to push the processing into sidekiq. Agreed? Also, the JSON isn't actual JSON in my env at least, it's like:
And so on. Otherwise, once the format and what attributes to include have been tweaked - would love to get this merged! |
Also one other thing. I think we should include the diaspora* version that exported the file from day one. The tricky thing is how to get this, since any develop version pods would just report @jhass any ideas? Kinda difficult how we replace the version in |
@@ -45,6 +47,8 @@ class User < ActiveRecord::Base | |||
has_many :invitations_from_me, :class_name => 'Invitation', :foreign_key => :sender_id | |||
has_many :invitations_to_me, :class_name => 'Invitation', :foreign_key => :recipient_id | |||
has_many :aspects, -> { order('order_id ASC') } | |||
has_many :posts, through: :person |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we outscope posts and comments from this pull, these two should be removed to be added later.
Maybe we should just give the export format its own version. Including the current release won't help much for the dev version, since you still don't know if it was |
Alright, finally got some time to sit down with this for a little bit. Should be ready for another look @jaywink |
def strategy(format) | ||
@strategy ||= case format | ||
when :json then Exporters::JSON | ||
when :xml then Exporters::XML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just drop everything related to the old XML user exporter? A community decision already accepted XML as the new format, the old one doesn't really work anyway.
Objections anyone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A community decision already accepted XML as the new format
Shurely JSON, not XML?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah :D
On 7 December 2014 16:19:03 EET, goob notifications@github.com wrote:
@@ -5,12 +5,24 @@
module Diasporaclass Exporter
- def initialize(strategy)
self.class.send(:include, strategy)
- def initialize(format = :json)
strategy(format).present?self.class.include strategy(format) if
- end
- def strategy(format)
@strategy ||= case format
when :json then Exporters::JSON
when :xml then Exporters::XML
A community decision already accepted XML as the new format
Shurely JSON, not XML?
Reply to this email directly or view it on GitHub:
https://github.com/diaspora/diaspora/pull/5354/files#r21424879
Br,
Jason Robinson
https://jasonrobinson.me
Thanks @gdpelican I'll check the export asap on my dev environment, hopefully tonight. I think this is pretty close, personally I think we should drop the XML stuff already. If no one objects within a few days, feel free to do it IMHO :) |
Quick test in dev env, looks ok to me. Note it's not prettyfied of course normally, I prettified it. One thing that needs fixing is that contacts don't show which aspect they have been added to. The one contact here below is in the "Friends" aspect, but the json doesn't show that in any way.
|
Also, date of birth is missing from the profile fields :) |
Also, something odd related to the exporter, but that is probably the fault of the profile system and not the exporter itself. Just after creating the profile it looks like this:
But after saving it once, it looks like this:
So we probably have a bug in profile creation, setting fields to null, since the save does things differently. |
f0035fe
to
e976fae
Compare
Cool, so I
Didn't get a chance to look at the null / "" profile name beyond having a chuckle at the |
Yeah I don't think you should worry about that in this PR. |
@@ -37,6 +37,8 @@ class User < ActiveRecord::Base | |||
serialize :hidden_shareables, Hash | |||
|
|||
has_one :person, :foreign_key => :owner_id | |||
has_one :profile, through: :person |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite a few tests are failing. I'm wondering if this is the cause? For example: AccountDeleter has all user association keys accounted for
Diff:
@@ -13,7 +13,6 @@
:invited_by,
:notifications,
:person,
- :profile,
:reports,
:services,
:tag_followings,
# ./spec/lib/account_deleter_spec.rb:175:in `block (2 levels) in <top (required)>'
So the tests need a little check through, whether things are really "breaking" or just tests need patching.
Also, if you could clean the commit message and add a Changelog entry - I think this would be ready for merging.
Pushed some test fixes, it seems like ActiveModelSerializer changes the default behaviour of (difference being Wonder if we should just turn off using the root element across the board for AMS, or if the tests passing is confidence enough that all the important json is still coming through correctly? |
Seems like there's still some frontend tests to fix up; I'll fix em up when I get the chance. |
68207df
to
bd8e524
Compare
Cool, looks like that build's passing now. Squashed 'er up and put in a message in the changelog as well. |
Hey, merge is close to you... :D |
## Json exporter functionality (Iteration 1) | ||
|
||
Allows users to export their data in JSON format from their user settings page | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an important feature, but the big headings are for things the podmin needs to read and know for update ;)
Just some minor remarks, then this should be good :) |
d417fb0
to
4ba9a64
Compare
@profile_deletion.perform! | ||
expect(@profile.reload.first_name).to be_blank | ||
expect(@profile.reload.last_name).to be_blank | ||
expect(@profile.reload.searchable).to be_falsey |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, slight optimization nitpick here, reload
returns self and updates the receiver, so just do it one time above the expectations.
4ba9a64
to
e174514
Compare
Alright, thank you! |
Thanks for your work on this, @gdpelican (and @jhass too). |
Nice! The first step for #5343 :D Thank you @gdpelican @jhass and @jaywink |
Just pulled this on d-fr, I tested it with my account (more than 1000 contacts). I put it in http://jsonlint.com/ and it says "valid" :) |
Awesome! Nice work @gdpelican! |
A quick first pass at a JSON exporter. Would welcome some feedback around which fields are required, useful, etc.
For #5343
Note that this hasn't touched the XML export functionality at all.