Mailing List Archive

Automatically expire events?
Hello all,

I'm looking for an automated way to delete entries older than X days from a calendar.


I found scripts/archive-old-events.php which seems to be quite close, but I don't
want the archive part.

From quickly skimming through the code, simply removing any reference to
$archive_collection_sql doesn't appear to do the trick.


What's the best way to go about this?


Any hints/pointers would greatly be appreciated.


Thanks and regards -- Till
--
Dipl.-Inform. Till Dörges doerges@pre-sense.de
Tel. +49 - 40 - 244 2407 - 14
Fax +49 - 40 - 244 2407 - 24
PRESENSE Technologies GmbH Sachsenstr. 5, D-20097 HH
Geschäftsführer/Managing Directors AG Hamburg, HRB 107844
Till Dörges, Jürgen Sander USt-IdNr.: DE263765024

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Davical-general mailing list
Davical-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/davical-general
Re: Automatically expire events? [ In reply to ]
Hi,

a workaround could be to create a trash calendar first.
Afterwards you can use this script or some sql to archive the entries
before day X.
And finaly delete the trash calendar.



Regards Martin

Am 06.02.2018 um 22:53 schrieb Till Dörges:
> Hello all,
>
> I'm looking for an automated way to delete entries older than X days from a calendar.
>
>
> I found scripts/archive-old-events.php which seems to be quite close, but I don't
> want the archive part.
>
> From quickly skimming through the code, simply removing any reference to
> $archive_collection_sql doesn't appear to do the trick.
>
>
> What's the best way to go about this?
>
>
> Any hints/pointers would greatly be appreciated.
>
>
> Thanks and regards -- Till


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Davical-general mailing list
Davical-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/davical-general
Re: Automatically expire events? [ In reply to ]
Am 07.02.2018 um 19:56 schrieb Martin Stöcker:

> a workaround could be to create a trash calendar first.
> Afterwards you can use this script or some sql to archive the entries before day X.
> And finaly delete the trash calendar.

I actually need a cron job (or something similar) to make sure that my calendar does
not contain any events older than X days.

So If I understand correctly I would have to

1) create a trash/archive collection
2) run scripts/archive-old-events.php on my calendar moving
stuff to the trash/archive collection
3) delete the trash/archive collection

I guess then I'll also have a look at scripts/davical-cli, which might help me with
1) and 3).

Thanks and regards -- Till
--
Dipl.-Inform. Till Dörges doerges@pre-sense.de
Tel. +49 - 40 - 244 2407 - 14
Fax +49 - 40 - 244 2407 - 24
PRESENSE Technologies GmbH Sachsenstr. 5, D-20097 HH
Geschäftsführer/Managing Directors AG Hamburg, HRB 107844
Till Dörges, Jürgen Sander USt-IdNr.: DE263765024

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Davical-general mailing list
Davical-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/davical-general
Re: Automatically expire events? [ In reply to ]
I just checked my sql-script that is used for archiving events.
I think it will do to delete calendar_item and caldav_data entries.
Besides you should pay a little attention to repeating events.

Regards Martin

Am 07.02.2018 um 20:17 schrieb Till Dörges:
> Am 07.02.2018 um 19:56 schrieb Martin Stöcker:
>
>> a workaround could be to create a trash calendar first.
>> Afterwards you can use this script or some sql to archive the entries before day X.
>> And finaly delete the trash calendar.
> I actually need a cron job (or something similar) to make sure that my calendar does
> not contain any events older than X days.
>
> So If I understand correctly I would have to
>
> 1) create a trash/archive collection
> 2) run scripts/archive-old-events.php on my calendar moving
> stuff to the trash/archive collection
> 3) delete the trash/archive collection
>
> I guess then I'll also have a look at scripts/davical-cli, which might help me with
> 1) and 3).
>
> Thanks and regards -- Till

--
Widdersdorfer Str. 415, 50933 Köln; Tel. +49 / 221 / 9544 010
HRB Köln HRB 75439, Geschäftsführer: S. Böhland, S. Rosenbauer


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Davical-general mailing list
Davical-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/davical-general
Re: Automatically expire events? [ In reply to ]
Hello all,

looked into it some more, but couldn't get it running. Any help would be appreciated.

I'm using the these version:

davical-1.1.7-2.noarch
libawl-php-0.59-2.noarch


I tested with this calendar:

https://some.host/davical/caldav.php/foo/bar/


>> So If I understand correctly I would have to
>>
>> 1) create a trash/archive collection
>> 2) run scripts/archive-old-events.php on my calendar moving
>> stuff to the trash/archive collection
>> 3) delete the trash/archive collection

1) does not seem to be required. At least archive-old-events.php creates a new
archive collection, if it doesn't exist already.


If I run ./archive-old-events.php like this

--- snip ---
user@box:/usr/share/davical/scripts> ./archive-old-events.php -o 'P-30D' -p foo -c
bar -s some.host -d all
--- snap ---

I get this output

--- snip ---
Archiving event instances finished before '20180128T181358Z'
UPDATE caldav_data
SET dav_name = replace( caldav_data.dav_name, :collection_dav_name,
:archive_dav_name),
collection_id = :archive_collection_id
FROM calendar_item
WHERE caldav_data.collection_id = :source_collection_id
AND caldav_data.caldav_type = 'VEVENT'
AND caldav_data.dav_id = calendar_item.dav_id
AND (
(rrule IS NULL AND dtend < :archive_before_date)
OR (last_instance_end is not null AND last_instance_end <
:archive_before_date)
)
--- snap ---

The archive collection https://some.host/davical/caldav.php/foo/bar-archive/ is created.

But an event that I created in foo/bar/ on Jan 2, 2018 is still there when looking at
my client.
It is not deleted.
However, something does seem to happen, because if I try to modify the test event
using my client, I get a complaint that the event has already been modified on the
server.

I'm a bit uncertain how to proceed. Any pointers would be welcome.


Am 08.02.2018 um 08:37 schrieb MS (direkt):

> I just checked my sql-script that is used for archiving events.
> I think it will do to delete calendar_item and caldav_data entries.
> Besides you should pay a little attention to repeating events.

Could you perhaps share your script?


>> I guess then I'll also have a look at scripts/davical-cli, which might help me with

FTR, scripts/davical-cli doesn't work on my openSUSE Leap 42.3 system. It looks like
the script has problems when parsing the output from 'ps'. Haven't looked into it any
further.


Thanks and regards -- Till
--
Dipl.-Inform. Till Dörges doerges@pre-sense.de
Tel. +49 - 40 - 244 2407 - 14
Fax +49 - 40 - 244 2407 - 24
PRESENSE Technologies GmbH Sachsenstr. 5, D-20097 HH
Geschäftsführer/Managing Directors AG Hamburg, HRB 107844
Till Dörges, Jürgen Sander USt-IdNr.: DE263765024

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Davical-general mailing list
Davical-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/davical-general
Re: Automatically expire events? [ In reply to ]
Hello all,

thanks for all the help! Unfortunately none really worked.


Am 27.02.2018 um 19:52 schrieb Jon:

> UPDATE caldav_data
>    SET dav_name = replace( caldav_data.dav_name, '/calendar/both/', '/calendar/both10/'),
>        collection_id = (SELECT collection_id FROM collection
>                          WHERE dav_name = '/calendar/both10/')
>   FROM calendar_item
>  WHERE caldav_data.dav_id = calendar_item.dav_id
>    AND caldav_data.collection_id = (SELECT collection_id FROM collection
>                                      WHERE dav_name = '/calendar/both/')
>    AND rrule IS NULL
>    AND dtstart < '2011-01-01';

I've tried the above in various forms (Jon's version, Martin's version, and the SQL
statement used by archive-old-events.php) and did investigate some more.

In all cases events older than the number of days specified appear to be *copied*
(rather than moved):

from https://some.host/davical/caldav.php/foo/bar/
to https://some.host/davical/caldav.php/foo/bar-archive/


Also my DAViCal client (Thunderbird) keeps complaining that the events which were
archived (more like copied in my case) were modified on the server.
But they are still shown in /foo/bar/ by Thunderbird.


Is that perhaps because the column 'dav_name' exists in both the tables caldav_data
and calendar_item, but is only updated in the former by the above statement?


I also experimented a bit with statements along the lines of

DELETE FROM caldav_data
WHERE collection_id = :source_collection_id
AND dav_id IN (
SELECT dav_id FROM calendar_item
WHERE ( (rrule IS NULL AND dtend < :archive_before_date)
OR (last_instance_end < :archive_before_date)
)
);

But couldn't get it working.


So I guess, I'm still looking for a way to either archive or delete events from a
calendar which are older than a certain number of days.


Regards -- Till
--
Dipl.-Inform. Till Dörges doerges@pre-sense.de
Tel. +49 - 40 - 244 2407 - 14
Fax +49 - 40 - 244 2407 - 24
PRESENSE Technologies GmbH Sachsenstr. 5, D-20097 HH
Geschäftsführer/Managing Directors AG Hamburg, HRB 107844
Till Dörges, Jürgen Sander USt-IdNr.: DE263765024

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Davical-general mailing list
Davical-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/davical-general
Re: Automatically expire events? [ In reply to ]
Hi Till,

I don't have time to look into this, so just some more thoughts to help
you investigate:

> > UPDATE caldav_data
> > ?? SET dav_name = replace( caldav_data.dav_name, '/calendar/both/', '/calendar/both10/'),
> > ?????? collection_id = (SELECT collection_id FROM collection
> > ???????????????????????? WHERE dav_name = '/calendar/both10/')
> > ? FROM calendar_item
> > ?WHERE caldav_data.dav_id = calendar_item.dav_id
> > ?? AND caldav_data.collection_id = (SELECT collection_id FROM collection
> > ???????????????????????????????????? WHERE dav_name = '/calendar/both/')
> > ?? AND rrule IS NULL
> > ?? AND dtstart < '2011-01-01';
>
> I've tried the above in various forms (Jon's version, Martin's version, and the SQL
> statement used by archive-old-events.php) and did investigate some more.
>
> In all cases events older than the number of days specified appear to be *copied*
> (rather than moved):
>
> from https://some.host/davical/caldav.php/foo/bar/
> to https://some.host/davical/caldav.php/foo/bar-archive/
>
>
> Also my DAViCal client (Thunderbird) keeps complaining that the events which were
> archived (more like copied in my case) were modified on the server.
> But they are still shown in /foo/bar/ by Thunderbird.

I would suggest to try and take Thunderbird out of the equation, because
it keeps its own calendar store and you want to be able to differentiate
between "event isn't moved properly on the server" and "changed event
isn't synced properly to TB". Enable GET on collections (or use curl to
send a caldav REPORT request) to see if the server still includes the
event in the non-archive collection. I could imagine the scripts failing
to generate a new sync token, and hence TB failing to find out about the
change until it tries to modify a changed event.

> Is that perhaps because the column 'dav_name' exists in both the tables caldav_data
> and calendar_item, but is only updated in the former by the above statement?

I would expect this to be taken care of by a function/trigger in the
database.

Florian

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Davical-general mailing list
Davical-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/davical-general