Skip to content

Commit 7784fe7

Browse files
committed
Fix issue #37: Add Badge and adjust developer size according to score
1 parent cca186e commit 7784fe7

File tree

3 files changed

+68
-20
lines changed

3 files changed

+68
-20
lines changed

src/app/custom/queries/query3/query3.component.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,25 @@ export class Query3Component implements OnInit {
431431
}
432432

433433
devSize() {
434+
if(this.size){
435+
let elements = this._g.cy.nodes(this.developers.map(x => '#n' + x).join());
436+
let devs = elements.filter((element) => element._private.classes.values().next().value == 'Developer');
437+
this._gt.knowAboutScore(devs, this.scores)
438+
this._gt.showHideBadges(true)
439+
}
440+
else {
441+
for (let i = 0; i < this.developers.length - 1; i++) {
442+
let element = this._g.cy.nodes('#n' + this.developers[i])[0];
443+
if (element._private.classes.values().next().value == 'Developer') {
444+
element.removeClass('graphTheoreticDisplay')
445+
}
446+
447+
}
448+
this._gt.showHideBadges(false)
449+
450+
}
451+
452+
/*
434453
if (this.size) {
435454
for (let i = 0; i < this.developers.length - 1; i++) {
436455
let element = this._g.cy.nodes('#n' + this.developers[i])[0]
@@ -489,7 +508,7 @@ export class Query3Component implements OnInit {
489508
}
490509
491510
}
492-
511+
*/
493512
}
494513

495514
private dateFilterFromUserPref(varName: string, isNode: boolean): string {

src/app/custom/queries/query4/query4.component.ts

+26-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { GroupingOptionTypes } from '../../../visuall/user-preference';
1313
import { GroupCustomizationService } from 'src/app/custom/group-customization.service';
1414
import { GENERIC_TYPE, LONG_MAX, LONG_MIN } from 'src/app/visuall/constants';
1515
import { TimebarGraphInclusionTypes } from 'src/app/visuall/user-preference';
16+
import { TheoreticPropertiesCustomService } from 'src/app/custom/theoretic-properties-custom.service'
1617
export interface DeveloperData {
1718
name: string;
1819
score: number;
@@ -57,7 +58,7 @@ export class Query4Component implements OnInit {
5758
currNodeSize = this.NODE_SIZE;
5859
algorithm = null;
5960

60-
constructor(private http: HttpClient, private _dbService: Neo4jDb, private _cyService: CytoscapeService, private _g: GlobalVariableService, private _group: GroupCustomizationService) {
61+
constructor(private http: HttpClient, private _dbService: Neo4jDb, private _cyService: CytoscapeService, private _g: GlobalVariableService, private _group: GroupCustomizationService, private _gt: TheoreticPropertiesCustomService) {
6162
this.files = [];
6263
this.developers = [];
6364
this.scores = [];
@@ -143,7 +144,7 @@ export class Query4Component implements OnInit {
143144
const f2 = this.dateFilterFromUserPref('b', true);
144145
let f = '';
145146
if (f1.length > 0) {
146-
f += ' WHERE ' + f1.substr(5);
147+
f += ' AND ' + f1.substr(5);
147148
}
148149
if (f2.length > 0) {
149150
f += f2;
@@ -154,10 +155,10 @@ export class Query4Component implements OnInit {
154155
}
155156
const r = `[${skip}..${skip + dataCnt}]`;
156157

157-
const cql = `MATCH path=(b:File {name : '${this.file}'})-[r*0..3]-(a:Developer) ${f}
158-
WHERE NONE(rel in relationships(path) WHERE type(rel) = 'COMMENTED')
158+
const cql = `MATCH path=(b:File {name : '${this.file}'})-[r*0..3]-(a:Developer)
159+
WHERE NONE(rel in relationships(path) WHERE type(rel) = 'COMMENTED') ${f}
159160
WITH reduce(prod = 1, edge IN relationships(path) | prod * edge.recency) AS multipliedRecency, a,r,b
160-
WITH DISTINCT ID(a) As id, a.name AS name,round(toFloat(SUM(multipliedRecency / size(r)^2)) * 100) / 100 AS score
161+
WITH DISTINCT ID(a) As id, a.name AS name,round(toFloat(SUM(multipliedRecency / size(r))) * 100) / 100 AS score
161162
RETURN id, name, score ORDER BY ${orderExpr} LIMIT ${this.number}`;
162163
this._dbService.runQuery(cql, cb, DbResponseType.table);
163164

@@ -191,6 +192,7 @@ export class Query4Component implements OnInit {
191192
this.graphResponse = x;
192193
}
193194
this.clusterByDeveloper();
195+
this.devSize();
194196
};
195197

196198

@@ -376,6 +378,24 @@ export class Query4Component implements OnInit {
376378

377379
}
378380
devSize() {
381+
if(this.size){
382+
let elements = this._g.cy.nodes(this.developers.map(x => '#n' + x).join());
383+
let devs = elements.filter((element) => element._private.classes.values().next().value == 'Developer');
384+
this._gt.knowAboutScore(devs, this.scores)
385+
this._gt.showHideBadges(true)
386+
}
387+
else {
388+
for (let i = 0; i < this.developers.length - 1; i++) {
389+
let element = this._g.cy.nodes('#n' + this.developers[i])[0];
390+
if (element._private.classes.values().next().value == 'Developer') {
391+
element.removeClass('graphTheoreticDisplay')
392+
}
393+
394+
}
395+
this._gt.showHideBadges(false)
396+
397+
}
398+
/*
379399
if (this.size) {
380400
for (let i = 0; i < this.developers.length - 1; i++) {
381401
let element = this._g.cy.nodes('#n' + this.developers[i])[0]
@@ -436,7 +456,7 @@ export class Query4Component implements OnInit {
436456
}
437457
438458
}
439-
459+
*/
440460
}
441461

442462
private dateFilterFromUserPref(varName: string, isNode: boolean): string {

src/app/custom/theoretic-properties-custom.service.ts

+22-13
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@ import { formatNumber } from '@angular/common';
55
import { CytoscapeService } from '../visuall/cytoscape.service';
66
import { debounce2, debounce, COLLAPSED_EDGE_CLASS, mapColor } from '../visuall/constants';
77
import { Subscription } from 'rxjs';
8+
89
@Injectable({
910
providedIn: 'root'
1011
})
1112
export class TheoreticPropertiesCustomService {
1213

14+
15+
private _adjustSizeMethods: { name: string, fn: any }[];
16+
get adjustSizeMethods(): { name: string, fn: any }[] {
17+
return this._adjustSizeMethods;
18+
}
19+
20+
21+
22+
1323
isOnSelected = false;
1424
isDirectedGraph = false;
1525
isMapNodeSizes = true;
@@ -27,9 +37,9 @@ export class TheoreticPropertiesCustomService {
2737
currNodeSize = this.NODE_SIZE;
2838
appDescSubs: Subscription;
2939

30-
constructor(private _g: GlobalVariableService, private _cyService: CytoscapeService) { }
40+
constructor(private _g: GlobalVariableService, private _cyService: CytoscapeService) {
3141

32-
ngOnInit() {
42+
this._adjustSizeMethods = [{ name: 'By know about score ', fn: (elems, scores) => { this.knowAboutScore(elems, scores) } }];
3343
this._cyService.setRemovePoppersFn(this.destroyCurrentPoppers.bind(this));
3444
this._g.cy.on('remove', (e) => { this.destroyPopper(e.target.id()) });
3545
this._g.appDescription.subscribe(x => {
@@ -39,11 +49,6 @@ export class TheoreticPropertiesCustomService {
3949
});
4050
}
4151

42-
ngOnDestroy(): void {
43-
if (this.appDescSubs) {
44-
this.appDescSubs.unsubscribe();
45-
}
46-
}
4752

4853
runProperty() {
4954
this.cySelector = '';
@@ -68,15 +73,20 @@ export class TheoreticPropertiesCustomService {
6873
return 1;
6974
}
7075

71-
knowAboutScore (elems, scores: number []){
72-
console.log("come ere")
76+
knowAboutScore (elems, scores){
77+
this.cySelector = '';
78+
this.destroyCurrentPoppers();
79+
let m = Math.max(...scores);
80+
console.log(m)
81+
this.maxPropValue = m;
7382
for (let i = 0; i < elems.length; i++) {
7483
let badges = [0];
7584
badges = [scores[i]];
76-
this.generateBadge4Elem(elems[i][0], badges);
77-
78-
85+
this.generateBadge4Elem(elems[i][0], badges);
7986
}
87+
this._cyService.setNodeSizeOnGraphTheoreticProp(m, this.currNodeSize);
88+
this.setBadgeColorsAndCoords();
89+
8090
}
8191

8292
generateBadge4Elem(e, badges: number[]) {
@@ -85,7 +95,6 @@ export class TheoreticPropertiesCustomService {
8595
div.style.position = 'absolute';
8696
div.style.top = '0px';
8797
div.style.left = '0px';
88-
console.log("jhjh geldii")
8998
document.getElementById('cy').appendChild(div);
9099
this.isMapBadgeSizes = true;
91100
this.isMapNodeSizes = true;

0 commit comments

Comments
 (0)