mongodb differences between clients - mongodb-query

I'm very confused and I can't seem to find any explanations on the web. windowStart is a ISODate in my documents.
When using the mongodb-java-driver (via the mongoTemplate in Spring) the following works fine...
{windowStart : {$lt : new Date()}}
When I use MongoDb Compass GUI and type the above in the Filter it is marked as not valid. If I change it to...
{windowStart : {$lt : new Date('2018-10-01')}}
...then it is marked as valid and works
Another example...
{windowStart : {$gt : new Date(new Date('2018-10-01').getTime()+1000*60*60*24*64)}}
Does not work in mongodb-java-driver (via the mongoTemplate in Spring).
Does work in MongoDb Compass GUI
So I just can't work out what I can and cannot do. There is something I'm missing about how the client drivers work and the differences? I see lots of examples on the web for searching date ranges etc yet most don't work for me, so again I'm wondering what client they have been written for

In the below script, you will get data between the given date
{windowStart:{$gte:ISODate('2022-12-28'),$lte:ISODate('2022-12-29')}}

Related

Wrong "ReflectedWorkItemIDFieldName" while migrating Azure DevOps Work Items

I am testing the azure-devops-migration-tools and have create a project using https://azuredevopsdemogenerator.azurewebsites.net/ (Parts Unlimited). I have generated the configuration.json and changed the Source and Target so I can test a migration, but I'm getting errors while migrating Work Items.
[15:14:41 ERR] Error running query
Microsoft.TeamFoundation.WorkItemTracking.Client.ValidationException: TF51005: The query references a field that does not exist. The error is caused by «ReflectedWorkItemId».
I've tried different options on the "ReflectedWorkItemIDFieldName" field, Scrum, Basic, Agile, Custom, empty but am still unable to migrate the work items.
How can I get the value to put on this field for the specific project?
Thanks,
Bruno
Quick Solution: Most ADO instances use the prefix 'custom' for new fields. Try "Custom.ReflectedWorkItemId" in your configuration.json to see if that resolves the problem.
More details: It's hard to tell without an actual configuration.JSON file to review. One possible problem is that you need to use the actual and full internal 'Name' of the ReflectedWorkItemID field. This doesn't show in ADO, or the Process Template when created. The recommendation is that you create a query referencing your custom field, and export the WIQL file (query file). Once you export the WIQL file, you can then open the file and see the full syntax of the custom field.
Exporting Queries: If you don't know how to do this, it can be done with VisualStudio. If you don't know how to do that, you can install this extension. It's a handy WIQL import/Export and editor. Install, and your ADO Queries with have an Edit in WIQL Editor option. Create a query that exposes your 'ReflectedWorkItemID' as a column, then edit that query in the WIQL editor and see the full names of the Reflected Work Items ID Feild. https://marketplace.visualstudio.com/items?itemName=ottostreifel.wiql-editor
SELECT
[System.Id],
[System.WorkItemType],
[System.Title],
[System.AssignedTo],
[System.ChangedBy],
[Custom.ReflectedWorkItemId]
FROM workitems
WHERE ...
I found a possible solution. I have created a custom process, change the process from the projects to this new one and add a new field. This is the field I'm using on the configuration.json and now I'm able to migrate work items
To make the migration in the "ReflectedWorkItemIDFieldName" you must do:
"Organization Settings" -> Process -> Select the process where you project are (Basic, Scrum, Agil, or CMMI).
then click on the 3 dots and create a new Inherited process.
Then with the inherited process, you are able to create a new field for each work item type. The name that you type (could be "IronMan") that name will be in your configuration file.

Is using Javascript in odoo.fields.HTML possible?

I want to integrate Adobe Captivate Content (Export: index.html, along with src-folder) into ODOO Community Edition v13 e-Learning Module (website_slides).
The slide.slide model already offers slide_type 'webpage' alongside the field 'html_content'.
The field 'html_content' is of type odoo.fields.HTML. To get the requirement stated above to work, I need to embed Javascript in the given html_content. It seems like the JS-scripts are not working. I also tried with a simple Hello World script.
Can someone help?
Best regards,
Lars
I found the solution already.
Looking at odoo/fields.py -> class Html, you can see that by default the given value is being sanitized using odoo/tools/mail.py -> html_sanitize(), which removes the HTML-Elements in 'tags_to_kill'. 'tags_to_kill' also contains "script".
After overriding html_content in slide.slide with the following, the Javascript-code is being executed:
html_content = fields.Html(
sanitize=False,
sanitize_tags=False,
sanitize_attributes=False)

Bind Key Vault settings to class

In ASP.NET Core, if reading configuration from a JSON app.settings file I can bind a section to an object like this:
services.Configure<MyPocoConfig>(Configuration.GetSection("Section"))
Is there a straightforward way to do this with a group of settings that are read from Azure Key Vault? I am following the guide as described in the MSDN documentation here https://learn.microsoft.com/en-us/azure/key-vault/vs-key-vault-add-connected-service#access-your-secrets-in-code
I can manually map them like this:
services.Configure<MyPocoConfig>(myPoco =>
{
myPoco.Option1 = Configuration["Option1"];
myPoco.Option2 = Configuration["Option2"];
});
I just wondered if there was a way to automap them as it works for config stored in app.settings JSON. I'm sure it could be done with reflection but I was hoping there'd be a built in way.
I tried putting the settings into a category using the category--setting syntax described in the article and reading them with services.Configure<MyPocoConfig>(Configuration.GetSection("category")), but this doesn't work.
Edit:
It is now possible as of 2020 to put settings into a category using the category--setting syntax and read them like services.Configure<MyPocoConfig>(Configuration.GetSection("category"))
You can achieve the same by naming your Secret in the following pattern.
Section--Option1
Section--Option2
And you can use the following to get the values by section and .NetCore automatically maps it.
services.Configure<MyPocoConfig>(Configuration.GetSection("Section"))
Refer link https://learn.microsoft.com/en-us/aspnet/core/security/key-vault-configuration?view=aspnetcore-2.2#bind-an-array-to-a-class

How do I write a robust structural search template to report Mockito times(1)/Times(1) passed to verify in IntelliJ IDEA?

In my project Mockito.times(1) is often used when verifying mocks:
verify(mock, times(1)).call();
This is redundant since Mockito uses implicit times(1) for verify(Object), thus the following code does exactly what the code above does:
verify(mock).call();
So I'm going to write an a structural search drive inspection to report such cases (let's say, named something like Mockito.times(1) is redundant). As I'm not an expert in IntelliJ IDEA structural search, my first attempt was:
Mockito.times(1)
Obviously, this is not a good seach template because it ignores the call-site. Let's say, I find it useful for the following code and I would not like the inspection to trigger:
VerificationMode times = Mockito.times(1);
// ^ unwanted "Mockito.times(1) is redundant"
So now I would like to define the context where I would like the inspection to trigger. Now the inspection search template becomes:
Mockito.verify($mock$, Mockito.times(1))
Great! Now code like verify(mock, times(1)).call() is reported fine (if times was statically imported from org.mockito.Mockito). But there is also one thing. Mockito.times actually comes from its VerificationModeFactory class where such verification modes are grouped, so the following line is ignored by the inspection:
verify(mockSupplier, VerificationModeFactory.times(1)).get();
My another attempt to fix this one was something like:
Mockito.verify($mock$, $times$(1))
where:
$mock$ is still a default template variable;
$times$ is a variable with Text/regexp set to times, Whole words only and Value is read are set to true, and Expression type (regexp) is set to (Times|VerificationMode) -- at least this is the way I believed it should work.
Can't make it work. Why is Times also included to the regexp? This is the real implementation of *.times(int), so, ideally, the following line should be reported too:
verify(mockSupplier, new Times(1)).get();
Of course, I could create all three inspection templates, but is it possible to create such a template using single search template and what am I missing when configuring the $times$ variable?
(I'm using IntelliJ IDEA Community Edition 2016.1.1)
Try the following search query:
Mockito.verify($mock$, $Qualifier$.times(1))
With $Qualifier$ text/regexp VerificationModeFactory|Mockito and occurrences count 0,1 (to find it when statically imported also).
To also match new Times(1) you can use the following query:
Mockito.verify($mock$, $times$)
With $times$ text/regexp .*times\s*\(\s*1\s*\) and uncheck the Case sensitive checkbox.

ASP.net MVC: Execute Razor from DB String?

I was thinking about giving end users the ability to drop Partial Views (controls) into the information being stored in the database. Is there a way to execute a string I get from the database as part of the Razor view?
Update (I forgot all about this)
I had asked this question previously (which lead me to create RazorEngine) Pulling a View from a database rather than a file
I know of at least two: RazorEngine, MvcMailer
I have a bias towards RazorEngine as it's one that I've worked on but I have a much simpler one at Github called RazorSharp (though it only supports c#)
These are all pretty easy to use.
RazorEngine:
string result = RazorEngine.Razor.Parse(razorTemplate, new { Name = "World" });
MvcMailer
I haven't used this one so I can't help.
RazorSharp
RazorSharp also supports master pages.
string result = RazorSharp.Razor.Parse(new { Name = "World" },
razorTemplate,
masterTemplate); //master template not required
Neither RazorSharp, nor RazorEngine support any of the Mvc helpers such as Html and Url. Since these libraries are supposed to exist outside of Mvc and thus require more work to get them to work with those helpers. I can't say anything about MvcMailer but I suspect the situation is the same.
Hope these help.