forked from MapComplete/MapComplete
Scripts: redo analysis, small updates
This commit is contained in:
parent
2fede3a631
commit
904c4573aa
1 changed files with 21 additions and 9 deletions
|
@ -60,7 +60,7 @@ export default class GenerateReviewsAnalysis extends Script {
|
||||||
geojsonFeatures.push({
|
geojsonFeatures.push({
|
||||||
geometry: {
|
geometry: {
|
||||||
type: "Point",
|
type: "Point",
|
||||||
coordinates: [lon, lat],
|
coordinates: [lon, lat]
|
||||||
},
|
},
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
properties: {
|
properties: {
|
||||||
|
@ -69,20 +69,28 @@ export default class GenerateReviewsAnalysis extends Script {
|
||||||
opinion: review.opinion,
|
opinion: review.opinion,
|
||||||
client: review.metadata.client_id,
|
client: review.metadata.client_id,
|
||||||
nickname: review.metadata.nickname,
|
nickname: review.metadata.nickname,
|
||||||
affiliated: "" + review.metadata.is_affiliated,
|
affiliated: "" + review.metadata.is_affiliated
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("Total number of reviews", reviews.length)
|
console.log("Total number of reviews", reviews.length)
|
||||||
|
|
||||||
|
|
||||||
|
const aliases = ["mapcomplete.osm.be", "pietervdvn.github.io", "dev.mapcomplete.org", "127.0.0.1:1234", "localhost:1234"]
|
||||||
|
for (const alias of aliases) {
|
||||||
|
clientWebsites["mapcomplete.org"] += clientWebsites[alias]
|
||||||
|
delete clientWebsites[alias]
|
||||||
|
}
|
||||||
this.print("Website", clientWebsites)
|
this.print("Website", clientWebsites)
|
||||||
|
|
||||||
this.print("Theme", themeHist)
|
this.print("Theme", themeHist)
|
||||||
this.print("language", languageHist)
|
this.print("language", languageHist)
|
||||||
const fc: FeatureCollection = {
|
const fc: FeatureCollection = {
|
||||||
type: "FeatureCollection",
|
type: "FeatureCollection",
|
||||||
features: geojsonFeatures,
|
features: geojsonFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
const fcmc: FeatureCollection = {
|
const fcmc: FeatureCollection = {
|
||||||
|
@ -91,20 +99,24 @@ export default class GenerateReviewsAnalysis extends Script {
|
||||||
(f) =>
|
(f) =>
|
||||||
f.properties.client.indexOf("mapcomplete") >= 0 ||
|
f.properties.client.indexOf("mapcomplete") >= 0 ||
|
||||||
f.properties.client.indexOf("pietervdvn.github.io") >= 0
|
f.properties.client.indexOf("pietervdvn.github.io") >= 0
|
||||||
),
|
)
|
||||||
|
}
|
||||||
|
if (!fs.existsSync("./reviews-analysis")) {
|
||||||
|
fs.mkdirSync("./reviews-analysis")
|
||||||
}
|
}
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
"../MapComplete-data/reviews.geojson",
|
"./reviews-analysis/reviews.geojson",
|
||||||
|
|
||||||
JSON.stringify(fc),
|
JSON.stringify(fc),
|
||||||
{ encoding: "utf-8" }
|
{ encoding: "utf-8" }
|
||||||
)
|
)
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
"../MapComplete-data/reviewsmc.geojson",
|
"./reviews-analysis/reviewsmc.geojson",
|
||||||
|
|
||||||
JSON.stringify(fcmc),
|
JSON.stringify(fcmc),
|
||||||
{ encoding: "utf-8" }
|
{ encoding: "utf-8" }
|
||||||
)
|
)
|
||||||
|
console.log("See ./reviews-analysis for the output")
|
||||||
}
|
}
|
||||||
|
|
||||||
async main(args: string[]): Promise<void> {
|
async main(args: string[]): Promise<void> {
|
||||||
|
@ -151,10 +163,10 @@ export default class GenerateReviewsAnalysis extends Script {
|
||||||
"rating",
|
"rating",
|
||||||
"opinion",
|
"opinion",
|
||||||
"images",
|
"images",
|
||||||
"metadata",
|
"metadata"
|
||||||
]
|
]
|
||||||
return new Promise<Review[]>((resolve) => {
|
return new Promise<Review[]>((resolve) => {
|
||||||
const parser = parse({ delimiter: "," }, function (err, data) {
|
const parser = parse({ delimiter: "," }, function(err, data) {
|
||||||
const asJson: Review[] = []
|
const asJson: Review[] = []
|
||||||
for (let i = 1; i < data.length; i++) {
|
for (let i = 1; i < data.length; i++) {
|
||||||
const line = data[i]
|
const line = data[i]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue