nextcloud / polls

🗳️ Polls app for Nextcloud
https://apps.nextcloud.com/apps/polls
GNU Affero General Public License v3.0
257 stars 73 forks source link

Make time of voting activity available #3760

Open Bibo-Joshi opened 3 weeks ago

Bibo-Joshi commented 3 weeks ago

⚠️ This issue respects the following points: ⚠️

Describe the goal you'd like to achieve

As a poll owner, I want to be able to know when a user voted, because it helps me updating prelimenary plans that I have made based on the votes before the polls end date.

Describe possible solutions

Whenever a user votes for the first time or changes their vote, store the current unix timestamp. Add it to the response of the /api/v1.0/poll/{pollId}/votes endpoint.

Additional context

Since for these tasks I usually query the data via the API rather than the GUI, it suffice for me to have this info available via the API. Showing the timestamps in the GUI could be an addition later on. Moreover, I don't need the history of all voting changes the user made, just the timestamp of the last activity.

dartcafe commented 2 weeks ago

You can track the changes from the Activity app. Individual vote timestamps are otherwise not tracked (excluding notifications).

Bibo-Joshi commented 2 weeks ago

Hey, thanks for the reply and the hint! I've looked arount a bit and found the api documentation of the activity app. From what I found out so far, it shows me only events of polls that were either triggered by me or are related to poll shares. Moreover, it does not show activity about me participating in polls but only about poll configuration changes etc. I extracted the following event types:

[
  "option_add",
  "poll_closed",
  "share_delete",
  "comment_delete",
  "share_change_type",
  "poll_delete",
  "share_add",
  "option_update",
  "share_registration",
  "poll_update",
  "poll_add",
  "poll_reopened",
  "poll_restore",
  "option_delete"
]

Maybe I'm missing something? But even if I can get the poll participation events from that API, I'm not so sure that this would be a feasible solution for me, as it would mean scraping the complete poll-activity log since the poll creating to filter out only the few events that are relevant for the specific poll I'm looking at 🤔

dartcafe commented 2 weeks ago

You also have vote_set

Find the events and their constants here: https://github.com/nextcloud/polls/tree/master/lib/Event

Bibo-Joshi commented 1 week ago

Thanks for the hint! I fiddled around a bit more, but I have additional questions

Filtering in the activity API

From what I tested, I get the following results

Can you help shed some light on this? Or should I reach out on the activities app repo?

Availability of events

It appears that I can only see events about someone voting in a poll if the poll is owned by me since before the vote took pace. I.e. owner transferral after the vote doesn't make the event visible to me. Am I observing this correctly or am I missing something? Is there a possibility for an admin to get all events for any poll via the activities API? I guess the next best thing would be parsing the db itself …

Iteration

Assuming that there is a way that i can see all relevant vote_set events, it looks like I need to

Am I understanding this correctly? If so, that doesn't seem very handy to me and I would repeat my suggestion to make the timestamp of vote_set available via the polls app api 😅