How do we know a survey_id to be able to call the API? - unique

The API calls require a survey_id.
There is a surveyID in the web link but that is an alphanumeric code that is not the same as the survey_id. eg https://www.surveymonkey.com/s/STB97HW is surveyID 47481373
The "Edit survey" pages do not show the surveyID. (by the way, I've just found that the category eg "Just for fun" is another one of those survey attributes not returned by get_survey_details)
So a user can not make a note of the surveyID for later querying.
A user can download a CSV file of data, as a pair of "Sheet_1.csv" and "Collectors.csv" but neither of those files contain a surveyID. It would be a useful enhancement if, given a data CSV download, one could query the surveys list to find the one that has a given CollectorID.
The user could copy the survey title into a query and search the survey list for ones that match, assuming they copy it correctly or spell it correctly if entering it. Or the query could be by a date range, to get a list of surveys, present them to the user, and ask them to pick the one they want.
Is there no way that a user can discover a surveyID, either when designing the survey or when it is closed, in order to uniquely specify it for retrieval without having to go through this search process?

You need to use the "get_survey_list" API to get a list of survey ids, you can then feed these into the other API methods.
Note that a survey link is actually an individual collector for that survey, and not directly associated with a survey - i.e. it is associated with a collector, which is then associated with a survey. You can have multiple links (or collection methods) for one survey that way. You can get a list of collectors for a given survey using get_collector_list. get_collector_list can also return the list of URL links for these collectors, if they exist.
There is currently no way to get a survey_id without going through this method - these survey ids are not meant to be visible to the end user, usually for API integrations a list of the user's surveys is presented to them (via the get_survey_list method) and then they select one. If you're interested, have a look at Mailchimp, Zendesk or Hootsuite's integrations.

Related

The best way to Fetch counts of depending entities in JPA

This question is actually for design suggestion.
Situation: I have a table Feed which contains feeds details like description date of creation, feed owner etc etc. I have two associated tables with feed "Likes", "Comments". Likes contains mapping of feed and user who liked feed, comments contains comment along with feedId and userId
I have to fetch Feed details of a particular feed along with below details:
Number of likes
Number of Comments
Whether User who requested feed details has liked feed or not
I have two ways to implement this but not sure which one is better with JPA and why or is there any other way
Solution 1:
I fetch feed details using a stored procedure which will take feedId and userId and will return feed details along with other data. As it will include more than one query, hence using the stored procedure, I can get all data in single call to database
Solution 2:
I fetch Feed details using entityManager.find() and use criteria to find count of likes, comment and whether user has liked feed or not. This will require 4 calls to the database.
If I fetch complete Feed object and fetch likers ugin feed.getLikers() and populate count and check liked by user then it might be costly if likers are in huge number.
I don't think using a stored procedure is good option when I'm using any ORM (JPA here) it will simply give me List which is not an entity (correct me if I'm wrong). Making 4 calls to populate entire entity is not good solution either.
Please suggest the best way to solve this.
Just for info and if required: I am using JPA with Spring boot

Different companies listed in Exact Online REST API system divisions and XML API Administrations

When I download the list of companies using the end point Administrations either through the user front end or directly using a HTTP GET, I receive an XML with contents such as:
<?xml version="1.0" encoding="UTF-8"?>
<eExact xsi:...>
<Administrations>
<Administration>
...
</Administration>
I can receive the list of companies also using the REST API system/divisions.
In general the number and names companies listed in both are equal, although some fields are present in XML API that are not present in the REST API and vice versa.
However, sometimes the contents are different. For instance, today I had scenario where there were only 2 companies listed in the XML topic, but over 900 in system/divisions.
This occurs both using the APIs directly as through Invantive SQL.
Why is the outcome different?
You can also use one of the four views:
AllAdministrations (similar to Administrations)
AllAdministrationCustomers (-)
AllAdministrationClassifications (similar to AdministrationClassifications)
AllAdministrationAssignedTypes (similar to AdministrationAssignedTypes)
These query the administrations across all subscriptions an accountant has access too.
All topic are read using a specific company (in the URL named division) to retrieve the data from.
System/divisions REST API returns ALL companies accessible for the current user, so the outcome does not depend on the division used in the URL request.
However, the XML topic Administrations returns ONLY companies accessible for the current user that are of the SAME customer account of the division used in the URL request.
A customer account is number of 1 or more companies which is independently billed. For entrepreneur licenses, this is generally the same list of companies.
However, for an accountant it differs what company is used, since they may have hundreds of different customers each with their own licenses plus many companies under their own customer code.
In general, it is more wise to use the system/divisions.
However, when you need additional fields or for instance the classifications of a company, you will need to use the XML API. The easiest way to determine the minimum number of companies to retrieve the XML API Administrations data for is to:
First retrieve all system/divisions.
For every different value of customercode, find one division, for instance the minimum value.
For each of these divisions, access the end point Administrations.
Combine the output of each of those.

Can i store multiple add-on for a product in column of table as JSON?

Prob: I have a table which contains list of toys(dolls).while purchasing user can choose options(black dress or white dress) and accessories(earring and anklet).
options 1: First i thought of adding 2 different table for options and accessories.
http://imgur.com/a/FnE6O
But as i am never going to filter/search on these table so i thought of putting these options as JSON in seperate column.So that frontend can easily render JSON as options to user
QUES: As i have to add total price from options and accessories
Is this ok to store these type of details as JSON format?
I am also open for other suggestions which is easily maintainable
If you are using an sql-database (and it looks like you are) I really advise you against keeping the data as JSON inside.
Even though MySQL 5.7.8 gives you a good way to access data inside json types, you never know when you are going to need to filter/search/group based in that data.
A quick example that jumps here is that you want to give a user that buys a new doll (productid == 1) a list of all the add-on that people that also bought that doll (productid == 1) purchased in the last week (or month). If you are going to save that data as JSON it will be very hard to query.
I know that your example shows only the meta-data of the add-ons and options, but it's "easy" to go and also save the actual purchases that way (just as add-on to the purchase-row itself).
I advise against it.

How to eliminate database table row duplication

I have a question on databases and how information is displayed in regards to Primary and Foreign keys.
For example, there are three tables; Employees, Employee_tickets and Employee_comments.
Each employeecan have multiple tickets and also multiple comments. A foreign key is placed in the Employee tickets and Employee Comments table. My application is built in vb.net with Visual Studio and it is a desktop application. How can I query say.. Employee Name ('Jon Doe') and display all of his tickets in a grid as well as all of the comments people have made on him over time? I have created a View on the sql database which returns all of the information I require but for each ticket listed under ('Jon Doe') the View displays and Employee Name for every single ticket. Is there a way to display the employee name only once and then every ticket listed under that particular individual without displaying the Employee Name again or do I have to make Separate windows to segregate all of this?
This seems like a really dumb question and I cannot for the life of me figure out how to correctly display what is required in this situation.
Here is an example of what I am trying to explain:
So for troy there is one employee name entered in the Employee Names table, There is one CWB ticket entered in the CWB table but there are TWO PQ Cards entered in the PQR Ticket table. How Can I Display only one row for Troy and one Row for his CWB because there are only one of each entered in the tables then the two rows for the PQR Cards under his name?
I have created a view which gathers this information all into the one single view itself then bound the datagridview's to this View.
Your problem has nothing to do with databases. Rather, the issue is that you have an entity (the employee) that has two separate collections associated with it (tickets and comments) and you want to show the contents of both collections.
Doing this in a datagrid is difficult because in its simplest incarnation it's intended to show one collection of like items.
I can think of a number of possibilities:
In your code, convert each collection to a single string value and display that single string value on the row with the employee's name. This conversion could be to comma-separate a stringified version of each item in the collection (as suggested by BS123 in the comments) or could simply be a summary (eg "5 Tickets").
Put the basic employee information in one data grid and then have two additional data grids below it, one bound to the Tickets collection and one to the Comments collection.
Embed data grids directly in the main data grid, one in the Tickets column and one in the Comments column, and bind each one to the appropriate collection in the employee.
Your database structure is correct so don't change that, you simply need to solve the issue of presentation.
What you're missing here is a controller between your view and your model. Your view is presenting exactly what it was given to present - it's up to you to format it.
There are several possible solutions to this, and the correct one partially depends on needs and infrastructure.
If you infrastructure is solid and your needs are near real time, consider dropping separately querying to fill your second and third tables based on what is picked in the first. This will increase the load on the database, but your data will almost always be correct, and the data will come from the database the way you want to see it.
If the database-centered solution is not good for you, LINQ provides some good ways to filter your data into typed collections that would present exactly what you want the user to see.
To get the users:
Dim users = From l In data.lines
Group By FirstName = l.firstName, LastName = l.lastName
Into Tickets = Group, Count()
You can then present this object to your grid. While dynamic typing works here, I think it would be easier to manage view interactions with defined classes. I'll leave that part up to you. Do some searching on LINQ to fill in the rest of the blanks. It's pretty neat stuff.

How to store / retrieve large amounts of data sets within XPages?

Currently we're working on a solution where we want to track (for analysis) the articles a user clicks on/opens and 'likes' from a given list of articles. Subsequently, the user needs to be able to see and re-click/open the article (searching is not needed) in a section on his/her personal user profile. Somewhere around the 100 new articles are posted every day. The increasing(!) amount of daily visitor (users) lies around the 2000 a day. The articles are currently stored and maintained within a MySQL Db.
We could create a new record in the MySQL Db for every article read / 'liked'. 'Worst case' would this create (2500 * 100 = ) 250000 records a day. That won’t hold long of course… So how would you store (process) this within XPages, given the scenario?
My thoughts after reading “the article” :) about MIME/Bean’s: what about keeping 'read articleObjects' in a scope and (periodically) store/save them as MIME on the user profile document? This only creates 100 articleObjects a day (or 36500 a year). In addition, one could come up with a mechanism where articleObjects are shifted from one field to another as time passes by, so the active scope would only contain the 'read articleObjects' from last month or so.
I would say that this exactly what a relational database is for. My first approach would be to have a managed bean (session scope) to read/access user's data in MySQL (JDBC). If you want, you can build an internal cache inside the bean.
For the presented use case, I would not bother with the JDBC datasources in ExtLib. Perhaps even the #Jdbc functions would suffice.
Also, you did not say how you are doing the analysis? If you store the information in Domino, you'll probably have to write an export tool.