Skip to content

Commit

Permalink
ブログ用にコミット
Browse files Browse the repository at this point in the history
  • Loading branch information
rei tamai committed Oct 12, 2020
1 parent c4dd4bf commit 8780e12
Show file tree
Hide file tree
Showing 10 changed files with 322 additions and 0 deletions.
41 changes: 41 additions & 0 deletions models/cm_tamai_naracrime.model.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
connection: "cm_snowflake"

include: "/views/*.view"

datagroup: cm_tamai_naracrime_default_datagroup {
max_cache_age: "1 hour"
}

persist_with: cm_tamai_naracrime_default_datagroup

explore: basic_info {
label: "奈良県犯罪情報(基本)"
}

explore: hit_bicycle {
label: "自転車盗"
}

explore: hit_car {
label: "自動車盗"
}

explore: hit_bike {
label: "オートバイ盗"
}

explore: aim_automat {
label: "自動販売機ねらい"
}

explore: aim_parts {
label: "部品ねらい"
}

explore: car_break_in {
label: "車上ねらい"
}

explore: grab {
label: "ひったくり"
}
13 changes: 13 additions & 0 deletions views/aim_automat.view.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include: "/views/extend_base.view"

view: aim_automat {
extends: [extend_base]
sql_table_name: "NARA_CRIME"."aim_automat" ;;

dimension: damage_cash {
label: "現金被害の有無"
type: yesno
sql: ${TABLE}."damage_cash" = 'あり' ;;
}

}
13 changes: 13 additions & 0 deletions views/aim_parts.view.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include: "/views/extend_base.view"

view: aim_parts {
extends: [extend_base]
sql_table_name: "NARA_CRIME"."aim_parts" ;;

dimension: damage {
label: "現金以外の主な被害品"
type: string
sql: ${TABLE}."damage" ;;
}

}
66 changes: 66 additions & 0 deletions views/basic_info.view.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
include: "/views/extend_base.view"

view: basic_info {
extends: [extend_base]

derived_table: {
sql: SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude"
FROM "NARA_CRIME"."aim_parts"
UNION
SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude"
FROM "NARA_CRIME"."grab"
union
SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude"
FROM "NARA_CRIME"."aim_automat"
union
SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude"
FROM "NARA_CRIME"."hit_bike"
union
SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude"
FROM "NARA_CRIME"."hit_bicycle"
union
SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude"
FROM "NARA_CRIME"."hit_car"
union
SELECT "RecordID","deception","precinct","police_booth","municipality","town","datetime_occurrence","attribute_occurrence","Latitude","Longitude"
FROM "NARA_CRIME"."car_break_in"
;;
}

dimension: deception {
label: "手口"
type: string
sql: ${TABLE}."deception" ;;
link: {
label: "詳細ダッシュボードへ"
url: "
{% if value == '自転車盗' %}
/dashboards/79?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }}
{% elsif value == 'ひったくり' %}
/dashboards/73?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }}
{% elsif value == 'オートバイ盗' %}
/dashboards/78?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }}
{% elsif value == '自動販売機ねらい' %}
/dashboards/78?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }}
{% elsif value == '車上ねらい' %}
/dashboards/76?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }}
{% elsif value == '自動車盗' %}
/dashboards/77?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }}
{% elsif value == '部品ねらい' %}
/dashboards/75?市区町村= {{ basic_info.municipality._value }}&町丁目= {{ basic_info.town._value }}
{% endif %}
"
}
}

# dimension: deception {
# label: "手口"
# type: string
# sql: ${TABLE}."deception" ;;
# link: {
# label: "詳細ダッシュボードへ"
# url: "/dashboards/79?発生場所={{ basic_info.location._value }}"
# }
# }

}
19 changes: 19 additions & 0 deletions views/car_break_in.view.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include: "/views/extend_base.view"

view: car_break_in {
extends: [extend_base]
sql_table_name: "NARA_CRIME"."car_break_in" ;;

dimension: damage_cash {
label: "現金被害の有無"
type: yesno
sql: ${TABLE}."damage_cash" = 'あり' ;;
}

dimension: lockup {
label: "施錠関係"
type: yesno
sql: ${TABLE}."lockup" = '施錠した' ;;
}

}
89 changes: 89 additions & 0 deletions views/extend_base.view.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
view: extend_base {
extension: required

dimension: record_id {
primary_key: yes
hidden: yes
type: number
sql: ${TABLE}."RecordID" ;;
}

dimension: deception {
label: "手口"
type: string
sql: ${TABLE}."deception" ;;
}

dimension: precinct {
label: "管轄警察署(発生地)"
type: string
sql: ${TABLE}."precinct" ;;
}

dimension: police_booth {
label: "管轄交番・駐在所(発生地)"
type: string
sql: ${TABLE}."police_booth" ;;
}

dimension: municipality {
label: "市区町村(発生地)"
type: string
sql: ${TABLE}."municipality" ;;
}

dimension: town {
label: "町丁目(発生地)"
type: string
sql: ${TABLE}."town" ;;
}

dimension_group: datetime_occurrence {
label: "発生年月日時(始期)"
type: time
sql: ${TABLE}."datetime_occurrence" ;;
}

dimension: attribute_occurrence {
label: "発生場所の属性"
type: string
sql: ${TABLE}."attribute_occurrence" ;;
}

dimension: latitude {
hidden: yes
type: number
sql: ${TABLE}."Latitude" ;;
}

dimension: longitude {
hidden: yes
type: number
sql: ${TABLE}."Longitude" ;;
}

dimension: location {
label: "発生場所"
type: location
sql_latitude: ${latitude} ;;
sql_longitude: ${longitude} ;;
}

measure: count {
label: "件数"
type: count
drill_fields: [detail*]
}

set: detail {
fields: [
datetime_occurrence,
deception,
municipality,
town,
attribute_occurrence,
location
]
}

}
25 changes: 25 additions & 0 deletions views/grab.view.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include: "/views/extend_base.view"

view: grab {
extends: [extend_base]
sql_table_name: "NARA_CRIME"."grab" ;;

dimension: damage_cash {
label: "現金被害の有無"
type: yesno
sql: ${TABLE}."damage_cash" = 'あり' ;;
}

dimension: age_aggrieved {
label: "被害者の年齢"
type: string
sql: ${TABLE}."age_aggrieved" ;;
}

dimension: sex_aggrieved {
label: "被害者の性別"
type: string
sql: ${TABLE}."sex_aggrieved" ;;
}

}
25 changes: 25 additions & 0 deletions views/hit_bicycle.view.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include: "/views/extend_base.view"

view: hit_bicycle {
extends: [extend_base]
sql_table_name: "NARA_CRIME"."hit_bicycle" ;;

dimension: age_aggrieved {
label: "被害者の年齢"
type: string
sql: ${TABLE}."age_aggrieved" ;;
}

dimension: job_aggrieved {
label: "被害者の職業"
type: string
sql: ${TABLE}."job_aggrieved" ;;
}

dimension: lockup {
label: "施錠関係"
type: yesno
sql: ${TABLE}."lockup" = '施錠した' ;;
}

}
25 changes: 25 additions & 0 deletions views/hit_bike.view.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include: "/views/extend_base.view"

view: hit_bike {
extends: [extend_base]
sql_table_name: "NARA_CRIME"."hit_bike" ;;

dimension: damage {
label: "現金以外の主な被害品"
type: string
sql: ${TABLE}."damage" ;;
}

dimension: lockup {
label: "施錠関係"
type: yesno
sql: ${TABLE}."lockup" = 'キーあり' ;;
}

dimension: antitheft_device {
label: "盗難防止装置の有無"
type: yesno
sql: ${TABLE}."antitheft_device" = 'あり' ;;
}

}
6 changes: 6 additions & 0 deletions views/hit_car.view.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include: "/views/hit_bike.view"

view: hit_car {
extends: [hit_bike]
sql_table_name: "NARA_CRIME"."hit_car" ;;
}

0 comments on commit 8780e12

Please sign in to comment.