You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

635 lines
20 KiB

---
layout: post
type: handbook
title: "psisRecord"
date: 2013-11-12
tags: database
---
Now all data in the past will be in another database. MongoDB it is.
### เปาหมาย
*อมลทเกบไวจะตองมมากพอทจะสรางรายงานใหมไดนท โดยไมโอกาสทจะมอมลหายไปได เชน ขอมลไรสาระอยางรายละเอยดเพมเตมอยางตวอยางคำอธบายตวยอคาคงทจะไมจำเปนตองใสเพราะซำซอนและสามารถเรยกไดแนนอน ทกเวลาจากฐานขอมลหล
*อมลจะตองเขาถงงายเพอสรางรายงานเปรยบเทยบใหบสำนกงานตางๆ ได
### buffer
เปนสวนทการคำนวณขอมลเพอเกบไวสำหรบรายงานตอๆไป หลกๆ คอ ms* report เทานนทใชสำหรบตอนน
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "*",
...
}
#### report
1. ms_est_receipt
2. ms_actual
3. ms_actual_receipt
4. ms_actual_diff_receipt
5. ms_matrix
าหนงสอเรยน ใบเสรจ ประมาณการ
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "ms_est_receipt",
"data": {
...
}
}
าหนงสอเรยน นกเรยนทอยจรง Jun 10
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "ms_actual",
"data": {
...
}
}
าหนงสอเรยน ใบสำคญรบขอเบกเพมเตม Jun 10
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "ms_actual_diff_receipt",
"data": {
...
}
}
าหนงสอเรยน นกเรยนทอยจรง Nov 10
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "ms_actual",
"data": {
...
}
}
าหนงสอเรยน ใบสำคญรบขอเบก Nov 10
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "ms_actual_receipt",
"data": {
...
}
}
## report
หลกๆ ขอมลตรงนเอาไวออกรายงานโดยทไมจำเปนตองประมวลผลจากขอมลใหม (หรอขอมลดบไมแลว) รายงานกประมาณ
1. sub1
1. sub2
1. sub3
1. sub4
1. sub5
1. sub6
1. salary
1. payment
1. sub4_fake
1. ms_est
1. ms_est_receipt
1. ms_actual_jun10
1. ms_actual_jun10_receipt
1. ms_matrix
1. ms_actual_nov10
1. ms_actual_nov10_receipt
### รายงาน อน.1
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "sub1",
"is_charity": true/false,
"data": {
'disabled': {
'sum': 0,
'shift': [
{}, # day shift
{}, # night shift
]
},
'normal': {
'sum': 0,
'shift': [ ## list consisting of 0, 1 indicating shift
{ # shift start
u'1-0': { # grade and course
'text': {'grade': '1', 'course': u'0'},
'number':
{
'boarding': 0,
'normal': 296,
'tuition': 1937.0,
'disabled': 0,
'rate': {'normal': 7793.0, 'charity': 0}
}
}
},
{
... # another shift if applied
}
]
},
"total": {
'normal': {
'0': {'normal':0, 'charity':0, 'sum':0},
'1': {'normal':0, 'charity':0, 'sum':0},
'all':{'normal':0, 'charity':0, 'sum':0},
},
'disabled': {
'0': {'disabled':0, 'boarding':0, 'sum':0},
'1': {'disabled':0, 'boarding':0, 'sum':0},
'all': {'disabled':0, 'boarding':0, 'sum':0},
},
}
}
### รายงาน อน.2
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "sub2",
"is_charity": true/false,
"data": {
'0': { # shift !
'0': { # coarse grade
'sum': {
'abs_total': 0,
'charity': 0, 'normal': 0, 'boarding': 0, 'disabled': 0,
'teachers': 0, 'salary': 0,
},
'crs': [
{ # room thing and teacher data
"room": xx, "all_students": 0, "boarding": 0, "disabled": 0, "eligible": 0,
"full_name": xxx, "education": yyy, "employment_date": yyyy-mm-dd,
"employment_document_number": xxx, "salary": 0
},
{},
{},
],
'extra': [
{ # only teacher data
"full_name": xxx, "education": yyy, "employment_date": yyyy-mm-dd,
"employment_document_number": xxx, "salary": 0
},
{},
{},
]
},
'1': { # coarse grade
},
},
'1': { # shift if applied
},
},
"total": {
'0': {'abs_total': 0, 'normal': 0, 'boarding': 0, 'disabled': 0, 'teachers': 0, 'salary': 0,},
'1': {'abs_total': 0, 'normal': 0, 'boarding': 0, 'disabled': 0, 'teachers': 0, 'salary': 0,},
'all': {'abs_total': 0, 'normal': 0, 'boarding': 0, 'disabled': 0, 'teachers': 0, 'salary': 0,}
}
}
### รายงาน อน.3
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "sub3",
"is_charity": true/false,
"data": {
}
}
### รายงาน อน.4
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "sub4",
"is_charity": true/false,
"data": {
}
}
### รายงาน อน.5
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "sub5",
"is_charity": true/false,
"data": {
}
}
### รายงาน อน.6
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "sub6",
"is_charity": true/false,
"data": {
}
}
### บญชการจายเงนเดอนคร
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "salary",
"is_charity": true/false,
"data": {
}
}
### หลกฐานการจายเงนเดอนคร
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "payment",
"is_charity": true/false,
"data": {
}
}
### ขอมลเกบเผอสราง อน.4 ยอนหล
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"), # report_date
"report": "sub4_fake",
"data": {
# student detail count enough to feed ReportSub4Mixin.get_processed_data()
}
}
## stat
### original data
This is what data with all grades; no dob cut; no student_status considered; no issue considered; but we only sum student in class. Student without class is out of luck ever. This is a pure query.
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"),
"type": "original",
"data": {
}
}
### raw data without any cut
Raw data which met basic requirements, no further cut. (shift isn't considered) This should meet few requirements:
* eligible grade
* verified & completed classroom
* date of birth
* student_status
* resolved issue students
From get_subsidized_students_queryset() w/o any cut.
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"),
"type": "raw",
"data": {
}
}
นร. ประเภทสามญศกษา ททธบเงนอดหนนรายบคคล
Data from get_subsidized_students_in_fine_grade()
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"),
"type": "educational",
"data": {
}
}
นร. ประเภทอาชวศกษา ททธบเงนอดหนนรายบคคล
Data from get_subsidized_students_in_fine_grade()
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"),
"type": "technical",
"data": {
}
}
นร. พการในโรงเรยนเอกชน ประเภทสามญศกษา
Filter verified disabled people from get_subsidized_students_queryset().
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"),
"type": "disabled_educational",
"data": {
}
}
นร. พการในโรงเรยนเอกชน ประเภทอาชวศกษา
Filter verified disabled people from get_subsidized_students_queryset().
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"),
"type": "disabled_technical",
"data": {
}
}
นร. โรงเรยนการกศล และโรงเรยนสอนศาสนาอสลามควบคบวชาสามญทลน/มสยดเปนผบใบอนญาต
Data from evaluate_errors() which (school).is_charity() has to return True
{
"_id": xx,
"school": "<school_id>",
"date": ISODate("xxx"),
"type": "charity",
"data": {
}
}
## history
เปนการเกบขอมลนกเรยนเขา-ออกทงหมด จาก `archive_students_transfer`
{
"_id": xx,
"people_id": "<people_id>",
"date": ISODate("xxx"),
"transfer": "in/out",
"school": "<school_id>",
... # depending on whether it's transfer IN/OUT
}
data is pretty much the same way sub5/sub6 is.
## searchArchive
* school [yearly data]
* teacher [monthly data in/out only]
* student [every in/out]
* report [not implemented -- using report]
### school
{
"_id": xx,
"archive_type": "school",
"school": "<school_id>",
"basic": {
"thai_name": "<thai_name>",
"eng_name": "<eng_name>",
"serv_area_code": "<serv_area_code>",
},
"board": {
"licensee": {"people_id": "", "full_name": "",},
"manager": {"people_id": "", "full_name": "",},
"principle": {"people_id": "", "full_name": "",},
},
"bank": {
"account_number": "",
"account_name": "",
"bank": "",
"bank_branch": "",
},
"license": [
{
"license_number": "",
"license_date": "",
"license_effective_date": "",
"age": [min, max],
"shift": {
"0": {"capacity": 0, "room": 0, "time": ["0", "0"], "grade": ["0", "0"]},
"1": {"capacity": 0, "room": 0, "time": ["0", "0"], "grade": ["0", "0"]},
}
},
## more items
{}, {}, ...
]
}
### teacher
{
"_id": xx,
"archive_type": "teacher",
"school": "<school_id>",
"people_id": "",
"full_name": "",
"transfer_type": "<in/out>",
"date": ISODate("xxx"),
"editor": "<user_id>"
}
### student
{
"_id": xx,
"archive_type": "student",
"school": "<school_id>",
"people_id": "",
"full_name": "",
"transfer_type": "<in/out>",
"xfer_status": "<DC/RM/QT/GD/RL/DN/CF/IW/II/IO>",
"student_id": "",
"date": ISODate("xxx"),
"editor": "<user_id>"
}
### confirmation
อมลในสวนยนยนขอมลถกตองในสวนตางๆ
วนยนยนของโรงเรยน
นยนความถกตองประจำป (เฉพาะเดอน 6)
นยนความถกตองประจำเดอน
วนยนยนคณภาพของขอมลของสำนกงาน
นยนการยนเอกสาร
นยนความถกตองของขอม
วนยนยนของโรงเรยน - ยนยนความถกตองประจำป (เฉพาะเดอน 6)
{
"_id": xx,
"user_id": 000,
"username": "<username> or <email>",
"date": ISODate("xxx"),
"school": "<school_id>",
"what": "confirmation",
"type": "monthly", # only student for now.
}
วนยนยนของโรงเรยน - ยนยนความถกตองประจำเดอน
{
"_id": xx,
"user_id": 000,
"username": "<username> or <email>",
"date": ISODate("xxx"),
"school": "<school_id>",
"what": "confirmation",
"type": "yearly", # only student for now.
}
วนยนยนคณภาพของขอมลของสำนกงาน - ยนยนการยนเอกสาร
{
"_id": xx,
"user_id": 000,
"username": "<username> or <email>",
"date": ISODate("xxx"),
"school": "<school_id>",
"office": "<office_id>",
"what": "dataQuality",
"type": "delivered",
}
วนยนยนคณภาพของขอมลของสำนกงาน - ยนยนความถกตองของขอม
{
"_id": xx,
"user_id": 000,
"username": "<username> or <email>",
"date": ISODate("xxx"),
"school": "<school_id>",
"office": "<office_id>",
"what": "dataQuality",
"type": "completeness",
}
### preferences
System-wide's key-value storage.
no. | name | value | description
--- | --- | --- | ---
1 | `subsidy_rate_header` | text |
2 | `ms_est_first_level_cut` | decimal 0-1 |
__System Preferences__ | via <br/> `core.get_system_pref()` `core.set_system_pref() `| |
--- | --- | --- | ---
3 | `enforce_disability_expiration_date` | boolean
4 | `enforce_people_id_validation` | boolean
5 | `backfill_reviews_in_progress` | boolean | no more running repetitive back-filling reviews ever
6 | `check_student_issue_in_progress` | boolean | no more running repetitive task
7 | `check_teacher_issue_in_progress` | boolean | no more running repetitive task
8 | `sub4sum_in_progress` | boolean | no more running repetitive task
9 | `sub4sum_office_in_progress` | boolean | no more running repetitive task
วเรองของ subsidy rate
{
"_id": xx,
"year": "2013",
"name": "subsidy_rate_header",
"value": "xxxxxxxxxxx",
"user": "<user_pk>",
"username": "<username>",
"date": "utc"
}
ตราตดของการสนบสนนตามการประมาณการของเรยนฟร 15 ป
{
"_id": xx,
"year": "2013",
"name": "ms_est_first_level_cut",
"value": "xxxxxxxxxxx", # 0-1 (or 0-100%) [default 0.8]
"user": "<user_pk>",
"username": "<username>",
"date": "utc"
}
การบงคบใชนหมดอายของนกเรยนพการ
{
"_id": xx,
"name": "enforce_disability_expiration_date",
"value": "true/false", # boolean
"user": "<user_pk>",
"date": "utc"
}
การบงคบการตรวจสอบเลขประจำตวประชาชนทงหมด
าเปด true -- จะทำใหเลขประจำตวประชาชนทดหลกและยงไมไดตรวจสอบไมไดบอดหน
าปด false -- เลขประจำตวทดหลกและยงไมไดตรวจสอบกจะไดบอดหน
{
"_id": xx,
"name": "enforce_people_id_validation",
"value": "true/false", # boolean
"user": "<user_pk>",
"date": "utc"
}
## userPreferences
าตางๆ ทเกยวกบ user โดยตรง
{
"_id": xx,
"key": "logout_3rd_party_all_together",
"value": "True/False",
"user": "<user.pk>"
}
จะเปนคาในกรณองการออกจากระบบของ Google/Yahoo ดวย (Facebook ยงไม sign out เองอตโนม) เหมาะกบเครองทไมใชของตวเองเพราะจะไดไม sign in พวกนางไวาออกจาก PSIS กออกจาก Google/Yahoo ใหวยทนท [ซงนนคอคา default]
## userData
{
"_id": xx,
"date": "utc",
"user": "<user.pk>",
"name": "",
"value": "",
}
ตอนนจะเกบเพยงแค task_id ซงจะถกลบหลงผานไป 2-3 วน เพราะยงไง celery result task กไมเกบหลงจากนนอย
name | value
--- | ---
task_id | <many many character>