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

Make time of voting activity available #3760

Open
1 task done
Bibo-Joshi opened this issue Oct 26, 2024 · 4 comments
Open
1 task done

Make time of voting activity available #3760

Bibo-Joshi opened this issue Oct 26, 2024 · 4 comments

Comments

@Bibo-Joshi
Copy link

⚠️ 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
Copy link
Collaborator

dartcafe commented Nov 4, 2024

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

@Bibo-Joshi
Copy link
Author

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
Copy link
Collaborator

dartcafe commented Nov 6, 2024

You also have vote_set

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

@Bibo-Joshi
Copy link
Author

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

  • /ocs/v2.php/apps/activity/api/v2/activity?format=json gives objects with object_type = poll and type = vote_set (among others)
  • /ocs/v2.php/apps/activity/api/v2/activity/filter?format=json&object_type=poll" gives only objects with object_type = '' and type = circles_*. I would have expected this to return all objects with object_type = poll and nothing else.
  • /ocs/v2.php/apps/activity/api/v2/activity/polls?format=json" gives objects with object_type = poll and type as listed in Make time of voting activity available #3760 (comment) but not vote_set. I would have expected this to return all kinds of poll events

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

  • make repeated calls to the activities api with different offets
  • keep track of all vote_set events
  • check if I'm still missing a vote_set event for one of the votes in the poll
  • stop the iteration once I found all

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 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants