Skip to content
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

feat: OCC and OCS Calendar Import/Export #6596

Closed

Conversation

SebastianKrupinski
Copy link
Contributor

@SebastianKrupinski SebastianKrupinski commented Dec 30, 2024

Summary

This adds the ability to export calendars via the OCS and OCC.

OCC Export

Command: calendar:export
Arguments: userId calendarId format filepath

OCC Import

Command: calendar:import
Arguments: userId calendarId format filepath
Options: errors, validation, supersede, show-created, show-updated, show-skipped, show-errors

OCS Export

Endpoint: /ocs/v2.php/calendar/export
Request: GET/POST
{
"id": "personal",
"fmt": "xcal", (optional "ical, jcal, xcal", defaults to "ical")
"user": "user1" (optional admin permissions required)
}

Performance

  • Export performance bottle neck seems to be CPU core max out due to single process execution, tests on dev setup with 16k of events takes about 5min or 60 items / second
  • Import performance bottle neck seems to be database write performance, tests on dev setup with 16k of events, takes about 30min or 10 items / second

TODO

  • Tests

Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 23.00%. Comparing base (599c890) to head (7ab487b).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #6596   +/-   ##
=========================================
  Coverage     23.00%   23.00%           
  Complexity      475      475           
=========================================
  Files           252      252           
  Lines         12110    12110           
  Branches       2299     2311   +12     
=========================================
  Hits           2786     2786           
  Misses         8997     8997           
  Partials        327      327           
Flag Coverage Δ
javascript 14.54% <0.00%> (ø)
php 59.30% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tcitworld
Copy link
Member

I think it feels odd to have this in the calendar as other calendar commands are into the dav namespace.

Comment on lines 68 to 65
'jcal' => '["vcalendar",[["version",{},"text","2.0"],["prodid",{},"text","-\/\/IDN nextcloud.com\/\/Calendar App\/\/EN"]],[',
'xcal' => '<?xml version="1.0" encoding="UTF-8"?><icalendar xmlns="urn:ietf:params:xml:ns:icalendar-2.0"><vcalendar><properties><version><text>2.0</text></version><prodid><text>-//IDN nextcloud.com//Calendar App//EN</text></prodid></properties><components>',
default => "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//IDN nextcloud.com//Calendar App//EN\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like hardcoding things here. Would it be possible to serialize an empty calendar to get the start string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I don't like hard coding this either. But I could not think of a better way to do this.

Yes, I could serialize a empty object but then I would still have to do fancy string manipulations to separate the beginning form the closing. Then output the beginning, then the objects, then the closing, as the output is a generated stream directly to the http buffer.

The only way to do this without hard coding would be to generate the calendar in memory and serialize it all as one. So it was a trade of hard coding or php memory exhaustion when exporting large calendars.

@SebastianKrupinski
Copy link
Contributor Author

I think it feels odd to have this in the calendar as other calendar commands are into the dav namespace.

I wasn't sure where we wanted to put this, as the code can export any calendar, from any calendar provider, so its not just for DAV, it can easily be moved to server code. I will ask about it once CW is back.

@SebastianKrupinski SebastianKrupinski force-pushed the enh/issues-563-calendar-import-export branch 2 times, most recently from c8dc1be to 320079f Compare January 26, 2025 17:18
@SebastianKrupinski SebastianKrupinski force-pushed the enh/issues-563-calendar-import-export branch from 03ef58c to 7ab487b Compare January 27, 2025 21:38
@SebastianKrupinski
Copy link
Contributor Author

All code moved to server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress
Projects
Status: ☑️ Done
Development

Successfully merging this pull request may close these issues.

2 participants