Retrieve list of article specifed by a locale (Directus Translation) - directus

i have an issue with filter M2M data. I want to retrieve list of article specifed by a locale (directus translation scenario)
have tried many way but these doesn't work
articles/rows?filters[translations.locale_id][eq]=2
articles/rows?filters[article_translations.locale_id][eq]=2
articles/rows?filters[locales.id][eq]=2
here is the schemas:
articles(id, publish_date, translations: translations interface)
locales(id, name, code)
articles_translations(id, article_id: FK,locale_id: FK, title, content)
Thank for your help !
enter image description here
Additionally, in admin app I got query error when filtering by column translations so I think it doesn't support from admin app

Related

How to get user from User field LookupId

I have a list in sharepoint online.
And in this list, i have a person field.
When i call the API endpoint to get all the items in the list, i get an LookupId value for the person field.
I tried to get the user by using the value of the lookupid, but it don't work because the id is not recognized.
The lookupid is a int (eg: 21) instead of a guid.
Is there something missing in the configuration of the person field or in my calls to Microsoft Graph API ?
When a user signs into a SharePoint site collection for the first time, a ListItem is created in a hidden User Information List. The LookupId in a PersonOrGroup field refers to the ListItem in this list. The URL for the User Information List for SharePoint Online should be:
https://{yourTenant}.sharepoint.com/{yourSiteCollection}/_catalogs/users/detail.aspx
Since the User Information List is a generic SharePoint list, you can query the list via Graph. First, get the list id for the User Information List. An easy way to get the list id is to view the source for the User Information Site via Chrome and search for 'listId'. You should find a result like this:
"listId":"{yourListIdIsHere}"
Copy the id. By using the copied id, the id of your root site and the LookupId, you can get the ListItem in the User Information List:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{pasteCopiedListId}/items/{lookUpId}?$expand=Fields
The ListItem contains information about the user, such as the email, which can be used to identify the Azure user:
https://graph.microsoft.com/v1.0/users/{eMail}
Question: How could i get the hidden User Information List from Microsoft Graph?
If you do not want to use the 'trick' with Google Chrome to get the id, there is another way to get the site. Typically, if you want to get the id for any site, you would call:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists
However, you will not find the id of the User Information List, even if you include hidden sites. I do not know why. An additional problem seems to be, that you cannot filter lists by their name:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists?$filter=name eq 'users'
The query returns an error, that the provided filter statement is not supported. The only way to get the list without knowing the id seems to by using the property displayName of the list. However, the displayName is based on your localization. So, since I am from Germany, I can get the site by using the query:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists?$filter=displayName eq 'Benutzerinformationsliste'
You will need to replace Benutzerinformationsliste with your localized name. For EN replace it with 'User Information List'.
This returns the expected result:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('xxx')/lists(id,name,displayName)",
"value": [
{
"#odata.etag": "\"xxx\"",
"id": "xxx",
"name": "users",
"displayName": "Benutzerinformationsliste"
}
]
}
As you can see, the name of the list is 'users', so why the first filter statement does not work is a little mystery to me. Maybe someone here knows and can help out.
Some of the queries above don't work at the moment.
What I finally found as a good solution - after trying many many queries - is that you can do this by following the few steps below:
1- Get the GUID of the user information list.
Using the title of the list "User Information List" or the name "users" in the parameter "$filter" does not work.
Don't forget 'system' among the properties you select if you want to retrieve the hidden system-lists.
GET https://graph.microsoft.com/v1.0/sites('{site_id}')/lists?select=id,name,system
2- Filter the previous result in order to pick up the ID of the targeted list named 'users'.
By the way, applying this restriction "$filter=name eq 'users'" does not work.
You will get an exception. So you must do the filtering part by writing a few lines of code.
3- Once you've got the list identifier, then select all the items you want. And voilĂ ! The word 'Fields' must be in pascal case (uppercase the first letter ).
GET https://graph.microsoft.com/v1.0/sites('{site_id}')/lists('users_list_id')/items?$select=Fields&$expand=Fields
As #QuestionsPS1991 mentioned, the people field in fact refers to the hidden user list. With the lookupid, we can get the user via below methods:
Get user by id
Get user property by expanding lookup field
//////////// updated
By default, MS Graph does not return this user list. You may hard code the list id or follow ##QuestionsPS1991 suggestion. Below is my test:

SharePoint change column id for REST requests

I recently started experimenting with the REST API for SharePoint 2013 Foundation and I am trying to return all entries in a list. My GET request returns the data I am looking for, but the IDs used to identify the columns in the list are not helpful for identifying what the information is (see images below). The column IDs between 'Title' and 'ID', in the second image, are a jumble of characters.
SharePoint List View
Response Data
Is there any way to configure the list to use the column names as IDs? Also, is there some significance to the characters currently used as IDs?
You will need to make a second request to get a listing of columns that includes the InternalName and the Title which is what you are trying to reference:
You can use this REST call:
_api/web/lists/GetByTitle('Project Details')/fields
or you can use CSOM:
using (ClientContext context = new ClientContext(url))
{
List list = context.Web.Lists.GetByTitle("Project Details");
context.Load(list, l => l.Fields);
context.ExecuteQuery();
foreach(Field field in list.Fields)
{
Console.WriteLine(field.Title);
Console.WriteLine(field.InternalName);
}
}
SharePoint automatically generates the InternalName and it is a read-only field, at least using REST. It'll be easier to get the Field Data to correlate the InternalName to the Title than changing the values.
The column you are referring to, between Title and Id, is the ID of the content type associated to the item. It is not a column ID.
The SharePoint REST API is OData compliant, so you can use the $select parameter to query for the neccesary fields.
http://server/site/_api/web/lists('guid')/items?$select=Column1,Column2
Please be aware though, lookup fields need to be expanded as well, otherwise you get only the Id of the lookup item.
http://server/site/_api/web/lists('guid')/items?$select=LookupColumn&$expand=LookupColumn/Title

Activity stream design with RavenDb

This is more of a design pattern / document design question than a technical one...
I want to display a activity feed on my website which will list all the latest happenings users have been doing on my site...here are some of the activities i would like to display:
New media uploaded (Bob has uploaded a new track)
Comments on a profile (Paul has commented on Bob's profile)
Comments on media (Steve has commented on Paul's track 'my track name')
Status updates (Steve can write any status update he wishes)
Each activity will need to have it's own set of data, such as the new media uploaded activity I would like to include details about the media such as image, title, description etc).
This activity will mostly be used as a global feed so it's the same for all users, although I need the option for users to only show feed items from users they are following (like twitter).
I think I have 2 options:
1) Pull in all the data Ad-Hoc with an index so the information is always up to date, even if a user alters his media title name...i'm not sure how well this will scale though??
2) Have an ActivityFeed document which contains a Sub-Document such as NewMediaUploadActivity (shown below).
ActivityFeed
- DateTime
- AccountId
- ActivityType
- Activity (this is a polymorphic object)
NewMediaUploadActivity : Activity
- MediaTitle
- MediaDescription
- GenreName
StatusUpdateActivity : Activity
- StatusText
ProfileCommentActivity : Activity
- CommentText
- ProfileAccountId
- ProfileUsername
Etc...
If anybody has any experience, or any input on the best way to do this in RavenDB I would be grateful, my live website built with SQL Server currently does what I need using a slightly modified option 2.
Paul
I would model this as:
public class ActivityTracking<TActivity>
{
public string[] AffectedUsers {get;set;}
public TActivity Activity {get;set;}
}
You can have different activities (not required to be in an inheritance hierarchy) that are "attached" to different users.
For example, Bob commenting on Jane's photo would show up in both streams.
You then can just query for activities for that user.

Database Design + Rails associations with :through using metadata

Here is the scenario: I am building a system that will let users search for each other based on their skill sets.
Users have skills. Skills are universal objects and are shared amongst users.
Users have the following metadata associated with skills: level and interest
Each user can create their own categories under which they can organize their skills (e.g. one user might have the skill "Saas" under "Front-End Development" and another under "Web Development")
I have 4 tables: Users, Skills, Categories & Skillsets
Assuming that John Doe (username: "johndoe") has the following categories and skill set:
Category: Front-End
Skills: HAML, SASS/SCSS, CoffeeScript, Javascript, jQuery
Category: Back-End
Skills: Ruby, Ruby on Rails, node.js
I'd like to be able to perform the following operations:
user = User.where(:username => "johndoe").first
user.categories
# returns a list of the user's categories
user.skills
# returns a list of the user's skills
user.category.where(name => "Front-End").first.skills
# => returns list of skills in the "Front-End" category
user.skills.where(:name => "HAML").first.category
# returns "Front-End" category
# adds a skill without assigning it to a category
user.skills << skill_object
user.skills.last.level = 9
user.skills.last.interest = 6
user.skills.last.save
# adds a skill while assigning it to a category
user.category.skills << skill_object
user.category.skills.last.level = 9
user.category.skills.last.interest = 6
user.category.skills.last.save
And in order to find users by skill:
skill = Skill.where(:name => "Javascript").first
skill.users
# returns users possessing skill
I've been playing around with my models for a while but not quite getting to behave as I'd like them to. I need a fresh perspective - Any pointers / suggestions?
I know nothing about Ruby, but from a relational db perspective, I'd probably just create a special, hardcoded, category field for each user: Uncategorized.
Then, when you add skills, they either go in a specified cateogory, or the default uncategorized one for that user. Outside of that one "special" record for each user, everything else would work perfectly no matter which skill or category you're looking at, and you can leave all your constraints in place without having to worry about null values.
UserID, User
1, me
CategoryID, UserID, Category
1,1,Uncategorized
2,1,Web GUI
SkillID, Skill
1,Javascript
2,Knitting
SkillID, CategoryID, Level, Interest
1,2,10,75
2,1,50,1
Depending on how you use Level and Interest, I'd also consider making them lookup tables to give meaning to the values from a database perspective (and help populate drop down lists).
etc.

Creating a good search solution

I have an app where users have a role,a username,faculty and so on.When I'm looking for a list of users by their role or faculty or anything they have in common I can call (among others possible)
#users = User.find_by_role(params[:role]) #or
#users = User.find_by_shift(params[:shift])
So it keeps the system
Class.find_by_property
So the question is: What if at different points users lists should be generated based on different properties.I mean: I'm passing from different links
params[:role] or
params[:faculty] or
params[:department]
to my list action in my users controller.As I see it all has to be in that action,but which parameter should the search be made by?
Try https://github.com/ernie/meta_search if you're on Rails 3