Get history of Document modifications/revisions in Azure Cosmos DB - json

I am looking for a sample code to get history of Document modifications , in the form of a list of Document versions in Azure Cosmos DB.
By selecting a document version from the list , that version will be displayed.
I also want to restore a previous document version .
I get the last version using the _ts tag.
However want a complete history of document revisions.
1. Maybe using Cosmos DB change feed.
2. Reading the ReadDocumentFeed
I have done some research . However did not come across any code for this.
Any pointers in this direction are most welcome.

Related

UI Testing (casperjs) with good known status of data (mysql database)

I'm using CasperJS for automated UI tests. I've done the basic UI testing and validation with some random data, kind of POC. I've set up this automation using bash script which kicks to start the web server, load MySQL data from SQL file, start CasperJS test cases, stop the web server, check the log files.
Now, I want to start the testing with some good known status of data which are stored in MySQL. So that I can test the list data and form data with detailed field information with some known database status. How should I know the status of data in the database at a moment?
1) Should I use pre-populated JSON dumped file which has status and details about all data?
2) Should I use web service API? (web service APIs are being used to show/save/delete data from the web page)
Let's take an example. I've 5 users in Users table. Now when I open the home page it shows 5 users with some rough details. When I click on any record from the list of users, it shows a form with detailed information about that user. The webpage is requesting to the web application to get the detail about a user with the help of user_id to show the detailed user data in a form. Now I want to check that all the data in that form is populated correctly. So at the next step, what would be the preferred way, should I read content from JSON dumped file or should I use web service API (like webpage does).
Searching this problem online, I also found MYSQL HTTP plugin. Should I consider this as well? and How safe it is to use? (I know from the docs that this plugin is not for the production, it is just for testing purpose only. :) )
For the main question in cases like this I would change the database connection string to your testing database (this is a clone).
In your case use your bash script to change the connection string (file copy?) automatically before you run the tests. And when completed change back.
Your testing database is a direct clone of your dev/live databsae but with ONLY the test data you want. Downside is you need to keep the schema in sync with DEV/LIVE.
Also another point to take into considertion is if your testing changes state (post). If so your testing data might be out of sync. One way is get around this is to drop foreign keys, truncate the data and load in a dump file.
HTH

Inconsistency in MS Graph API behaviour for onenote

When a section renamed get sections API doesn't reflect the updated name whereas get page api shows updated parent section name. This seems to be bug/ data inconsistency in ON API.
On change of anything at page level updates the lastModifiedDateTime for a section but nothing gets changed at notebook level. This again seems to be like some data inconsitency issue.
Can somebody clear this confusion.
(Note - All above can be tested using MS Graph API Explorer
)
These are two separate topics:
Section renaming
This is a known limitation/bug in OneNote - if you rename a section in OneNote Online (in your browser), then the API GET ~/notebooks/id/sections or GET ~/sections will give you the "old" name. This is because OneNote Online doesn't actually rename a file, it only marks the file as "to be renamed" - if you were to look at the file itself in OneDrive/SharePoint it would still have the old name.
Once the OneNote Native Client sees the section (for example OneNote for Windows) sees the section that has been marked as "to be renamed", it actually renames the file.
The OneNote API GET ~/sections/id/pages actually looks at the section binaries and is able to tell whether the section is renamed or not, which is why that name can be trusted as the "most up to date" one.
I have communicated this feedback to our team and we are exploring alternatives - I encourage you to start an item in uservoice so we can better understand impact.
https://onenote.uservoice.com/forums/245490-onenote-developer-apis
LastModifiedTime (LMT) on notebook/section clarifications:
The LMT of a section is equal to max(LMT of pages under it).
The LMT of a section group however is not max (LMT of sections and section groups under it). A section group is a folder and its LMT should behave like that of a folder in a traditional file system (reflects time of last add/delete of a file/folder directly under it).
However, there is nothing stopping you from using $expand and calculating the LMT (as you understand it) yourself based on the entities below the notebook/section group.
https://blogs.msdn.microsoft.com/onenotedev/2014/12/16/beta-get-onenote-entities-in-one-roundtrip-using-expand/

No Google BigQuery table created after importing data through webclient

I'm currently familiarizing myself with Google BigQuery by working through the examples at https://cloud.google.com/bigquery/web-ui-quickstart. Doing a query over the pubic datasets runs fine.
I run into problems when uploading custom data into a new table through the WebUI. I create a new dataset and table, and upload the csv file provided with the example case. As in the example I input the schema and submit the file. Now the upload window stays on top and turns grey as if it's working. Nothing seems to happen afterwards though. When clicking away the upload window after a long wait, the table seems to be created in the tree on the left. However, when clicking on the table an error is shown:
"Unable to find table: ndwtest-984:csvtest.csvdata"
This seems like a trivial action, however I cannot seems to get it to work. I've tried varies different files, uploaded the file to Google Cloud Storage first and played around with the advanced options the last two days, but keep getting the same error.
Help would be much appreciated.
Some steps to help you:
billing must be enabled
you need to choose to upload one single TXT file from the example eg: yob2013.txt and not the zip file
make sure the schema is entered as text: name:string,gender:string,count:integer
on the last screen of the wizard you don't need to change the default CSV option parameters (for demo purposes works as it is)
I just tried the example, and it does work for me. In case you still have errors, than you can check your Job History menu in the Web UI, direct link would be, warning you need to put your Id in the link.
https://bigquery.cloud.google.com/jobs/YOUR_ANONYMOUS_PROJECT_ID_HERE?pli=1

Google Realtime API - when to persist changes to database?

Scenario:
I have multiple browser clients whose internet connection varies from very fast to super slow. Because of that they might not see same state of a document.
I'm using Google shortcut file since the document is actually being stored in database.
saving document to database is triggered from client-side.
Question: how do I know which client got the most up to date document that should be saved to the database?
You are right that you can't rely on any particular client being the most up to date at a particular time. There is no easy way to determine that, since that can change at any given instant. (Although you can make sure that you don't have any unsaved changes in a particular client by looking at the document save state.)
Rather than trying to do this based on client state, you can use the export capability that is part of the Drive API, which will give you a valid snapshot of the data with a revision number so you can track what version you have.
Note that this is a brand new feature, so its not yet well documented. The response is a json object with the appId, revision number, and a data field which contains a json version of the document. It looks something like this, for a document that has a collab list "list" and collab string "text" in the root:
{"appId":"788242802491","revision":17,
"data":{"id":"root","type":"Map",
"value":{
"list":{"id":"gde9s8z5khjarls7o","type":"List","value":[]},
"text":{"id":"gdef98qdhiq679af","type":"EditableString","value":"This is a test 2."}}}}

Drupal node / data import issue

I have a client who needs to have data imported into drupal from a large spreadsheet. They already had the modules setup and I have the data all in the right tables... so it seems. I have run my own custom scripts to manipulate what was in the spreadsheets and exported / imported it into the drupal databases.
However, when I go to view that type of content in the backend, it shows there are multiple pages of data but displays "No content available." in every page. Here are the tables I imported to:
// for the business listing node type
field_data_field_bd_address_city
field_data_field_bd_address_street
field_data_field_bd_address_zip
field_data_field_bd_business_type
field_data_field_bd_contact_email
field_data_field_bd_contact_name
field_data_field_bd_description
field_data_field_bd_image
field_data_field_bd_listing_type
field_data_field_bd_phone
field_data_field_bd_tags
field_data_field_bd_website
// drupal default tables
node
node_comment_statistics
taxonomy_index
taxonomy_term_data
taxonomy_term_hierarchy
taxonomy_vocabulary
Am I missing any tables that I need to import data into to make connections?
I had this problem before and it took me a while to solve it. This was before anyone had mentioned the feeds module to me so I thought it was my only option.
If you're going to upload straight into your database you need to enter the data into the revisions tables as well. So you would have:
// for the business listing node type
field_data_field_bd_address_city
field_data_field_bd_address_street
field_data_field_bd_address_zip
field_data_field_bd_business_type
field_data_field_bd_contact_email
field_data_field_bd_contact_name
field_data_field_bd_description
field_data_field_bd_image
field_data_field_bd_listing_type
field_data_field_bd_phone
field_data_field_bd_tags
field_data_field_bd_website
And also:
// for the business listing node type
field_revision_field_bd_address_city
field_revision_field_bd_address_street
field_revision_field_bd_address_zip
field_revision_field_bd_business_type
field_revision_field_bd_contact_email
field_revision_field_bd_contact_name
field_revision_field_bd_description
field_revision_field_bd_image
field_revision_field_bd_listing_type
field_revision_field_bd_phone
field_revision_field_bd_tags
field_revision_field_bd_website
The same goes for the node table. This took me a while to work out and worked for me. Typically someone then mentioned the feeds module which would have saved me time but I thought I'd share what worked for me.
Instead of manually importing the data directly into the database and trying to figure out how to satisfy all the relational dependencies to make it work, I would suggest using the Feeds module
If you wish to continue with the manual process, perhaps this ER diagram of the Drupal database will help (keep in mind it is a bit dated and was likely based on earlier versions of Drupal 7).
I figured it out. I had to add data to the node_revision table with status of 1 set to all the nodes and it worked out just fine after that!