Forum OpenACS Development: News package notification bug

Collapse
Posted by Ryan Gallimore on
When a notification request is created on the news package on the same day as the release date for a news item, the notifications aren't sent.

When the notifications are swept, the request creation date must be less than or equal to the notification date. News currently sets the notification date to the publish date, which has a granularity of 'day'. The request creation_date is set to a full timestamp, but the notification date is set to the same day at midnight, never satisfying the condition.

Notifications will not be sent until a new item is sent on the next day.

I'd like to avoid adding minutes granularity to dates in the news package, as it explicity calls for days in the code. Does anyone have any suggestions for dealing with this issue?

Collapse
Posted by Ryan Gallimore on
Here's the fix to go in item-create-3.tcl:


if {[db_string pubdate "select to_date(:publish_date_ansi,'YYYY-MM-DD')"] eq [dt_sysdate]} {
set publish_date_ansi [dt_systime]
}

Collapse
Posted by Ryan Gallimore on
This revealed another problem when using the -subset switch in notification::new

The request object is created for the action_id a few ms after the publish_date. This notification is again missed by the sweeper b/c of the condition above.

I had to awkwardly set the acs_objects.creation_date of the request object to publish_date to resolve the problem.

I suspect this might be a problem outside of the news package. I'm happy to commit my fix if there's interest.

Collapse
Posted by Torben Brosten on
Why wait for interest to commit a fix?

Commit the fix. If someone has a problem with it, I'm sure they'll voice their solution soon enough.

cheers,

Torben

Collapse
Posted by Ryan Gallimore on
Well 1) my fix is a kludge - maybe someone else has a better idea, and 2) it's a core package so waiting for some feedback doesn't hurt.

I'm not surprised the news package has issues, but notifications is pretty solid. I guess the more esoteric subset support is not often used.

Collapse
Posted by Dave Bauer on
Wait.

Today at midnight is always before any other time during today. How does this not work?

ie: if I set the date to the current_date it is 2012-05-02

If I convert that to a timestamp it should be 2012-05-02 00:00:00

So if that is the notification time, it should be sent on any notification sweep after 2012-05-02 00:00:00

What am I missing?

Collapse
Posted by Ryan Gallimore on
Right, that's the problem, so the publish_date is 2012-05-02 00:00:00 which is *less* than the request creation date of, say, 2012-05-02 18:38:00.

The sweeper query requires that the request creation_date <= notif_date which in this case is the publish date down to the day. See notification/tcl/sweep-procs-postgresql.xql

The same issue appears when the subset feature is used since the request is created ms after the item.

Collapse
Posted by Dave Bauer on
Aha.

Ok so if someone requests notification for News at 10am on May 2 2012 then a new news item is created at 12pm on May 2 2012 the notification time is set to 12AM (00:00) on May 2, 2012 or time traveling back 12 hours to before the users subscribed.

OK, so the notification date for immediate publishing needs to be the creation timestamp correct?

This is the time that news should send to notifications pacakge.

Collapse
Posted by Ryan Gallimore on
Correct. My snippet above should fix it. It's a corner case since it only applies when you subscribe and an item is created on the same day. If the item is created in the future, you don't have to worry.
Collapse
Posted by Don Baccus on
So publish_date should be a timestamp, how hard is it to fix that?

I wouldn't worry about Oracle ...

Collapse
Posted by Don Baccus on
Can't use the creation_date as the notification shouldn't go out until the news item is actually published.
Collapse
Posted by Ryan Gallimore on
It's the creation date of the notification request acs_object, not the news item creation date.