Angular firebase , multiple filter query (orderByChild)

this.db.list(‘document’, ref => ref.orderByChild(‘filed1’).equalTo(true).ref.orderByChild(‘filed2’).equalTo(false)).valueChanges().subscribe(result=> {
//process result
});

Manikandan Ramakrishnan
about.me/manikandan.r
sig?u=manikandan.r
Advertisements

Multiple Django 2 Site on Appache 2

apache vhsot site 1

<VirtualHost *:80>
ServerName abc.site.com
WSGIDaemonProcess abcsite python-path=/djangopath1 python-home=/djangopath1/env
WSGIScriptAlias / /djangopath1/master_api/wsgi.py
WSGIProcessGroup abcsite
<Directory /djangopath1/master_api>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /djangopath1/>
WSGIProcessGroup abcsite
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

apache vhsot site 2

<VirtualHost *:80>
ServerName xyz.site.com
WSGIDaemonProcess xyzsite python-path=/djangopath2 python-home=/djangopath2/env
WSGIScriptAlias / /djangopath2/master_api/wsgi.py
WSGIProcessGroup xyzsite
<Directory /djangopath2/master_api>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /djangopath2/>
WSGIProcessGroup xyzsite
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

Deploy angular build in Apache

Normally Apache will through error,like when try to access http://localhost/login , apache will try to load folder called login.

To make this work , we can write rule in .htaccess as below

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ – [NC,L]
RewriteRule ^(.*) index.html [NC,L]

Make use you have enabled the rewire module in Apache.

And if you your using any folder in Apache like http://localhost/sub-folder/login, you have to specify the path while build the project as $ng build –base-href /sub-folder/

Django admin css not loading

When I have moved my project from MAC to windows, the admin page style are broken.
The css files are trying to load as admin/admin/css/….
so I have to specify the static config in settings.py as blow
old

STATIC_URL = os.path.join(BASE_DIR, ‘static/’)

new
STATIC_URL = ‘/static/’

STATIC_ROOT = os.path.join(BASE_DIR, ‘static’)

Now it looks good , no idea how it works on Linux with old config 🙂

Recursive relationship traversing same table – Django – Raw Query

For Example ,
employee is reporting to manager and being a manger to other employees. To drill down and get all the employees under him including sub managers and their reporting employees to N-level at single query

employees table
emp_id | manager_id
1 |
2 | 1
3 | 1
4 | 2
5 | 2
6 | 3
7 | 3
8 | 4
9 | 1
10 | 6

Raw query :

select id,manger_id ,emp_id from (select * from employees order by manger_id, emp_id) products_sorted, (select @pv := '1') initialisation where find_in_set(manger_id, @pv) and length(@pv := concat(@pv, ',', emp_id))

where @pv := ‘1’ is beginning point to start the travers

when the starting point is “1”, u will get all the record , when the starting point is 3 , you will receive 3=> 6,7 and 6=>10 , so total three record

Implementing in Django by raw query

class [Classname](ModelViewSet):
queryset = [Modlename].objects.all()
#by default get the report for logged in users
def get_queryset(self):
report_to_emp_id = self.request.user.id
return Reporting.objects.raw("select id,manger_id ,emp_id from (select * from employees order by manger_id, emp_id) products_sorted, (select @pv := '"+str(report_to_emp_id)+"') initialisation where find_in_set(manger_id, @pv) and length(@pv := concat(@pv, ',', emp_id)")

serializer_class = [SerilalizerClass]

This will list all the employees and including the sub levels

Run multiple MediaWiki Using single Parsoid

As you refer the installation of visual editor and Parsoid in previous post

We can see how to run multiple MediaWiki with single Parsiod Service.

Just change the Parsoid config to handle multiple domains as below

vim /etc/mediawiki/parsoid/config.yaml

Method 1: You can try to follow this one as per the document https://www.mediawiki.org/wiki/Extension:VisualEditor ,

mwApis: - 
# This is the only required parameter, 
# the URL of you MediaWiki API endpoint. 
 uri: 'http://path/to/my/wiki/api.php' 
 domain: 'localhost'
# and another MediaWiki 
 uri: 'http://path/to/my/otherwiki/api.php' 
 domain: 'another domain'

for me the Method 1 was not woking , so I did in my own way Method 2

Method 2:

conf: 
# For backwards compatibility, and to continue to support non-static 
# configs for the time being, optionally provide a path to a 
# localsettings.js file. See localsettings.example.js 
localsettings: ./localsettings.js

uncomment the localsettings: ./localsettings.js section

And comment all the demand and uri in the mwAPis section

mwApis: - 
# This is the only required parameter, 
# the URL of you MediaWiki API endpoint. 
#uri: 'http://path/to/my/wiki/api.php' 
#domain: 'localhost' .......

Create a new file in the Parsoid actual installed folder.

vim /usr/lib/parsoid/localsettings.js

Place the domain config here

'use strict'; 
exports.setup = function(parsoidConfig) { 
parsoidConfig.setMwApi({ uri: 'http://host1.com/api.php', domain: 'host1', prefix: 'host1' }); 
parsoidConfig.setMwApi({ uri: 'http://host2/api.php', domain: 'host2', prefix: 'host2' });

Make sure the above values should match with your MediaWiki config , example

$wgVirtualRestConfig['modules']['parsoid'] = array( // URL to the Parsoid instance // Use port 8142 if you use the Debian package 'url' => 'http://host1:8142',
// Parsoid "domain", see below (optional) 'domain' => 'host1', // Parsoid "prefix", see below (optional) 'prefix' => 'host1' );

Now , both host1 and host2 mediawiki can access the parsoid and use the Visualeditor smoothly.

Thank You 🙂